This topic describes how to connect and disconnect a remote host.
To send and receive the data packets, a connection must be established with a remote host. This tutorial describes the following:
The high level steps to connect to a remote host are as follows:
The RSocket::Connect()
function connects to a remote host.
The RSocket::Connect()
parameters identifies the
required type of socket connection. For more information, see important parameters .
For TCP sockets
An active connection
is made to the remote host. When the socket call completes successfully,
the socket can send and receive data. To create a connection, the
protocol must establish a network interface and a route to the destination.
For more information about this process and return values, see the RSocket::Connect()
function.
For UDP
For cancelling the connection
The RSocket::CancelConnect()
function cancels
the outstanding connect operation with a remote host. This function
also cancels any outstanding RSocket::Ioctl()
calls.
After this call, a socket can be reconnected by RSocket::Connect()
function.
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()
. An 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 |
ENormal |
Blocked reads and writes are terminated. No further data is accepted from the remote source and TCP disconnect is initiated. |
EStopInput |
Blocked reads are terminated. No further data is accepted from the remote source. |
EStopOutput |
Blocked writes are terminated. TCP disconnect is initiated. |
Eimmediate |
Blocked reads and writes are terminated. The connection is terminated by sending a reset. |