This topic describes how to access TCP/IP sockets.
Client programs access TCP/IP sockets through the generic socket
interface RSocket()
. The RSocket()
specifies
the protocol-specific behaviour through argument values. This tutorial contains
notes on the usage of RSocket()
functions for TCP and UDP
sockets.
The high level steps to access the TCP/IP sockets are as follows:
You must be familiar with RSocketServ()
and RSocket()
to
understand this tutorial.
The RSocket()
function
takes a number of parameters that determine the type of socket connection
to provide.
KAfInet
or KAfInet6
for
IPv6
sockType: KSockStream
for TCP/IP or KSockDatagram
for
UDP
protocol: KProtocolInetTCP
or KProtocolInetUDP
The following code is an example to access the TCP/IP socket:
void Example::open(void) { TInt err; RSocketServ ss; RSocket sock; err = ss.Connect(); err = sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp); // ... now connect to the socket to send and receive data