User`s guide
KwikNet TCP/IP Sockets
K
A
DAK
207
kn_recv kn_recv
Purpose Receive Data from a Connected Socket
Used by
n Task o ISP o Timer Procedure o Restart Procedure o Exit Procedure
Setup Prototype is in file KN_SOCK.H.
#include "KN_SOCK.H"
int kn_recv(int s, void *buf, int len, int flags);
Description S is a socket descriptor identifying the connected socket from which data
is to be received. Note that the socket must be connected either by
calling kn_connect() to connect or by calling kn_accept() to accept
a connected socket.
Buf is a pointer to storage for the received data.
Len is the buffer size, measured in bytes.
Flags is a control variable used to modify the receive process. Flags is 0
or the logical OR of any of the following values.
MSG_OOB Read out-of-band data.
MSG_PEEK Peek at the received data but do not remove the data
from the socket.
MSG_DONTWAIT Receive in non-blocking fashion.
Returns If successful, the number of bytes of data stored at *buf is returned.
If the socket is closed by the sender, the value 0 is returned.
On failure, the error status -1 is returned.
The error indicator for socket s is set to define the reason for failure. Use
kn_errno() to retrieve the error code.
EBADF The socket descriptor s is invalid.
EINVAL Parameter buf or len is invalid or
the buffer length len is declared to be less than 0 or
an error was encountered processing out-of-band data.
ENOTCONN The socket is not connected.
EMSGSIZE The buffer length is too small to receive the message
atomically as required by the socket protocol.
EWOULDBLOCK The socket is marked non-blocking or flags specifies
MSG_DONTWAIT and no data is available for reading.
ESHUTDOWN The peer has closed the connection and no data is
available for reading.
ENOBUFS Memory needed to service the request is unavailable.
...more