| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflsock.h" int read_TCP ( sock_t handle, /* Socket handle */ void *buffer, /* Buffer to receive data */ size_t length /* Maximum amount of data to read */ )
Reads data from the socket. On UNIX, VMS, OS/2, passes through to the standard read function; some other systems have particular ways of accessing sockets. If there is an error on the read this function returns SOCKET_ERROR. You can handle errors (in sockerrno) as fatal except for EAGAIN which indicates that the operation would cause a non-blocking socket to block, and EPIPE or ECONNRESET which indicate that the socket was closed at the other end. Treat EWOULDBLOCK as EAGAIN.
{ #if (defined (DOES_SOCKETS)) # if (defined (__UTYPE_BEOS)) return (recv ((SOCKET) handle, buffer, length, 0)); # elif (defined (__UNIX__) || defined (__VMS__) || defined (__OS2__)) return (read ((SOCKET) handle, buffer, length)); # elif (defined (__WINDOWS__)) int rc; /* Return code from call */ ASSERT (buffer); rc = recv ((SOCKET) handle, buffer, length, 0); return (win_error (rc)); # else # error "No code for function body." # endif #else return ((int) SOCKET_ERROR); /* Sockets not supported */ #endif }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |