![]() |
|
| << Previous | Index | Next >> | |
| | |
int sock_bytesready( void *s );
Description
For TCP sockets:
If the socket is in binary mode,
sock_bytesready()returns the number of bytes waiting to be read. If there are no bytes waiting, it returns -1.In ASCII mode,
sock_bytesready()returns -1 if there are no bytes waiting to be read or the line that is waiting is incomplete (no line terminating character has been read). The number of bytes waiting to be read will be returned given one of the following conditions:
- the buffer is full
- the socket has been closed (no line terminating character can be sent)
- a complete line is waiting
In ASCII mode, a blank line will be read as a complete line with length 0, which will be the value returned.
sock_bytesready()handles ASCII mode sockets better thansock_dataready(), since it can distinguish between an empty line on the socket and an empty buffer.For UDP sockets:
Returns the number of bytes in the next datagram to be read. If it is a datagram with no data (an empty datagram), then it will return 0. If there are no datagrams waiting, then it returns -1.
Parameters
s
- Pointer to a socket.
Return Value
-1: No bytes waiting to be read.0: If in ASCII mode and a blank line is waiting to be read;for DC 7.05 and later, a UDP datagram with 0 bytes of data is waiting to be read.>0: The number of bytes waiting to be read.Library
NET.LIB (Prior to DC 7.05, this was DCRTCP.LIB)
See Also
| TCP/IP Manual Vol 1 |
<<Previous | Index | Next>> | rabbit.com |