|
||
A connection to a remote host is made with RSocket::Connect()
.
RSocket::Connect()
takes a number of parameters which identify what kind of socket connection to provide. The important parameters for TCP/IP
or UDP are the addrFamily
, the sockType
and the protocol
. The following values should be used for TCP/IP.
addrFamily: KAfInet
or KAfInet6
for IPv6
sockType: KSockStream
(for TCP/IP) or KSockDatagram
for UDP
protocol: KProtocolInetTCP
or KProtocolInetUDP
For TCP sockets, an active connection is made to the remote host. When the socket call completes successfully, the socket
is ready to send and receive data. To form a connection, the protocol must establish a network interface and a route to the
destination. For details of this process, and further return values for RSocket::Connect()
.
As UDP is a connectionless protocol, Connect()
does not have to be called before writing data with RSocket::SendTo()
. It can be used to set the address for all data sent from the socket, in which case Send()/Write()
may be used in addition to SendTo()
.
Cancel an outstanding connect operation to a remote host with RSocket::CancelConnect()
. The call also cancels any outstanding RSocket::Ioctl()
calls.
After this call, a socket can be reconnected by RSocket::Connect()
.
A TCP socket can be set to listen with RSocket::Listen()
. The aDataOut
argument is ignored.
A connection request to a listening socket can be accepted with RSocket::Accept()
. A aConnectData
argument cannot be specified.
Use RSocket::Shutdown()
to asynchronously shut down a TCP. Disconnection data is not supported.
The following table describes the effects of different types of shut down for TCP:
Type |
Action |
|
Blocked reads and writes are terminated. No further data is accepted from the remote source, and TCP disconnect is initiated. |
|
Blocked reads are terminated. No further data is accepted from the remote source. |
|
Blocked writes are terminated. TCP disconnect is initiated. |
|
Blocked reads and writes are terminated. The connection is terminated by sending a reset. |