<< Previous | Index | Next >>

sock_awrite


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

Description

Write exactly len bytes to the socket or, if that amount of data can not be written, do not write anything. Unlike sock_fastwrite(), this function will never return less than the requested amount of data. This can be useful when the application needs to write a fixed amount of data, but does not wish to handle the transmission of only part of the data, as it would have to do if sock_fastwrite() was used.

len must be less than or equal to the socket transmit buffer size, otherwise sock_fastwrite() 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 containing data to write.

len

Number of bytes to write to the socket 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 has been closed for further transmissions, e.g., because sock_close() has already been called.

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

 0: Insufficient free space in the transmit buffer to satisfy the request, or len was zero. Try again later since the peer will eventually acknowledge the receipt of previous data, freeing up transmit buffer space.

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

Library

TCP.LIB

See Also

sock_fastread, sock_xfastread, sock_fastwrite, sock_xfastwrite, sock_axread, sock_aread, sock_axwrite


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