<< Previous | Index | Next >>

sock_aread


int sock_aread( tcp_Socket *s, byte *dp, int len );

Description

Read exactly len bytes from the socket or, if that amount of data is not yet available, do not read anything. Unlike sock_fastread(), this function will never return less than the requested amount of data. This can be useful when the application knows that it will be receiving a fixed amount of data, but does not wish to handle the arrival of only part of the data, as it would have to do if sock_fastread() was used.

len must be less than or equal to the socket receive buffer size, otherwise sock_fastread() must be used.

This function is only valid for TCP sockets. It is available starting with DC 7.30.

Parameters

s

Pointer to a TCP socket.

dp

Buffer to place bytes that are read.

len

Number of bytes to copy to the buffer.

Return Value

-1: len is greater than the total socket receive buffer size, hence this request could never be satisfied in one call.

-2: The socket is closed or closing, but insufficient data is in the buffer to satisfy the request.

-3: len < 0 or the socket parameter was invalid.

 0: Insufficient data is in the buffer to satisfy the request, or len was zero. Try again later since the socket is still able to receive data from the peer.

len: The len parameter is returned if there was sufficient data in the socket buffer to satisfy the request.

Library

TCP.LIB

See Also

sock_fastread, sock_xfastread, sock_fastwrite, sock_xfastwrite, sock_axread, sock_awrite, sock_axwrite


TCP/IP Manual
Vol 1
<<Previous | Index | Next>> rabbit.com