![]() |
|
| << Previous | Index | Next >> | |
| | |
int sock_fastread( tcp_Socket *s, byte *dp, int len );
Description
Reads up to
lenbytes fromdpon sockets. If possible this function fills the buffer, otherwise only the number of bytes immediately available, if any, are returned.Starting with Dynamic C 7.05, this function is only valid for TCP sockets. For UDP sockets, use
udp_recv()orudp_recvfrom(). Prior to 7.05, this function cannot be used on UDP sockets aftersock_recv_init()is called.Parameters
s
- Pointer to a socket.
dp
- Buffer to put bytes that are read.
len
- Maximum number of bytes to write to the buffer.
Return Value
- ≥
0: Success, number of bytes read.-1: Error.Library
TCP.LIB (Prior to DC 7.05, this was DCRTCP.LIB)
See Also
Example
Note that
sock_fastread()andsock_read()do not necessarily return a complete or single line; they return blocks of bytes. In comparison,sock_getc()returns a single byte at a time and thus yields poor performance.
do {
/* this function does not block */
len = sock_fastread(s, buffer, sizeof(buffer)-1);
if (len>0) {
buffer[len] = 0;
printf("%s", buffer);
}
} while(tcp_tick(s));
| TCP/IP Manual Vol 1 |
<<Previous | Index | Next>> | rabbit.com |