TutSocketRecvAll read multiple times from a socket until all data has been received
fd
socket file descriptor to read from
buf
buffer to put data into
size
number of bytes to read
flags
flags for recv
Number of bytes read if successful, -1
otherwise.
If TutSocketRecvAll fails, it returns -1
and sets the global SmartSockets error number to one of:
buf
was NULL
fd
was a negative number, or size
was less than 1
TutSocketRecvAll is a convenience function that keeps reading data from a socket until the desired number of bytes have been read, an error occurs, or EOF is reached. Unlike files, sockets can have data broken up into smaller packets for transmission over a network, and thus multiple reads are often necessary to allow time for all packets to arrive at the destination.
This function call normally blocks until size
bytes have been read from socket
. This behavior can be modified by setting the block mode using TutSocketSetBlockMode. The function TutSocketCheck can be used to determine if data is available to be read before calling TutSocketRecvAll.
The flags
argument can be any flags accepted by the recv function. Refer to your operating system manuals for full information on these flags. Specify 0
for flags
to use the default behavior.
None
TutSocketRecvTimeout, TutSocketCheck, TutSocketSetBlockMode
This example shows how to check if the desired number of bytes are read with TutSocketRecvAll:
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |