|
XSocket API
2.0
XIA Socket Library
|
Xrecv(), Xrecvfrom() - receive a message from a socket. More...
#include "Xsocket.h"Functions | |
| int | Xrecv (int sockfd, void *rbuf, size_t len, int flags) |
| Receive data from an Xsocket. More... | |
| int | Xrecvfrom (int sockfd, void *rbuf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen) |
| receives datagram data on an Xsocket More... | |
| int Xrecv | ( | int | sockfd, |
| void * | rbuf, | ||
| size_t | len, | ||
| int | flags | ||
| ) |
The Xrecv() call is used to receive messages from a connected Xsocket.
If no data is available at the socket, Xrecv() will wait for a message to arrive, unless the socket is nonblocking (see Xfcntl()), in which case the value -1 is returned and errno is set to EAGAIN or EWOULDBLOCK. This call will return any data available, up to the requested amount, rather than waiting for receipt of the full amount requested.
An application can use Xselect() or Xpoll(), or to determine when more data arrives on a socket.
| sockfd | The socket to receive with |
| rbuf | where to put the received data |
| len | maximum amount of data to receive. the amount of data returned may be less than len bytes. |
| flags | (This is not currently used but is kept to be compatible with the standard send socket call). |
| int Xrecvfrom | ( | int | sockfd, |
| void * | rbuf, | ||
| size_t | len, | ||
| int | flags, | ||
| struct sockaddr * | addr, | ||
| socklen_t * | addrlen | ||
| ) |
Xrecvfrom() retrieves data from an Xsocket of type XSOCK_DGRAM. Unlike the standard recvfrom API, it will not work with sockets of type XSOCK_STREAM.
If no data is available at the socket, Xrecvfrom() will wait for a message to arrive, unless the socket is nonblocking (see Xfcntl()), in which case the value -1 is returned and errno is set to EAGAIN or EWOULDBLOCK. This return any data available, up to the requested amount, rather than waiting for receipt of the full amount requested.
An application can use Xselect() or Xpoll(), or to determine when more data arrives on a socket.
| sockfd | The socket to receive with |
| rbuf | where to put the received data |
| len | maximum amount of data to receive. The amount of data returned may be less than len bytes. |
| flags | (This is not currently used but is kept to be compatible with the standard sendto socket call. |
| addr | if non-NULL, filled with the address of the sender on success |
| addrlen | contians the size of addr when called, replaced with the length of the received addr on return. addrlen MUST be set to the size of addr before calling Xrecvfrom() when addr is non-NULL. If addrlen is smaller than the length of the source DAG, the returned address is truncated and addrlen will contain length of the actual address. |
1.8.11