Sending and Receiving Data Tutorial

This topic describes how to send and receive data to a remote host.

Introduction

When the client connects to the remote host it can send and receive data packets to a remote host. This tutorial describes the following:

How to Send Data to a Remote Host

The RSocket::Send() and RSocket::SendTo() functions send the data to a remote host with a flag parameter option set.

How to Receive Data from a Remote Host

The RSocket::Recv(), RSocket::Read(), RSocket::RecvOneOrMore() and RSocket::RecvFrom() functions receive and read the data from a remote host.

The RSocket::Recv() and RSocket::Read() functions attempts to read the amount of data set by the size of the descriptor passed. These functions only complete when the descriptor is filled, or when the connection closes. If the descriptor is filled, the amount of data read is passed back in aLen. If the connection closes, the descriptor does not contain any data, and aLen should be ignored.

The RSocket::RecvOneOrMore() function is completed when data is available.

The RSocket::RecvFrom() function reads the first queued datagram. When it returns anAddr points to a TInetAddr object that holds the address of the remote source of the data. In UDP, if the socket is not bound to a local address and port, then binding is attempted.