TCP/IP Programming Manual

Errors
If an error occurs, the return value is set to -1 and the external variable errno is set to one of the
following values:
The specified socket was connected.EISCONN
The specified socket was shut down.ESHUTDOWN
An invalid argument was specified.EINVAL
Usage Guidelines
This is a nowait call; it must be completed with a call to the AWAITIOX procedure. For a
waited call, use recvfrom.
The parameters of the recvfrom_nw function are not compatible with those of the recvfrom
function in the 4.3 BSD UNIX operating system.
The length of the received data is given in the third parameter (count transferred) returned
from the AWAITIOX procedure. This length includes the address information given by
sizeof(sockaddr_in), sizeof (sockaddr_in6), or sizeof(sockaddr_nv) at
the beginning of the buffer.
For IPv6 use, define the variable r_buffer_ptr as a pointer to a structure of type
sockaddr_in6.
See Nowait Call Errors (page 86) for information on checking errors.
Examples
INET: the following programming example calls the recvfrom_nw function. In this example,
rsock is a socket created by a previous call to socket and fhost is a structure that receives
the address of the host from which the data is received. The data is received in buffer:
#include <socket.h>
#include <in.h>
#include <netdb.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <cextdecs(AWAITIOX, FILE_GETINFO_)>
..
struct sockaddr_in fhost;
int len,rsock;
char buffer [8*1024];
short error, rsock2, rcount;
long tag;
..
error = recvfrom_nw(rsock, buffer, sizeof(buffer), 0,
(struct sockaddr *) &fhost, &len, tag);
if error (!= 0) /* some error checking */
{
printf ("recvfrom_nw failed, error %d\n," errno);
exit (1);
}
rsock2=(short)rsock; /* AWAITIOX/FILE_GETINFO_ expects a short
for socket descriptor */
(void) AWAITIOX (&rsock2,,&rcount,&tag,1l);
(void) FILE_GETINFO_ (rsock2, &error);
if (error != 0)
{
printf ("error from AWAITIOX, error %d\n", errno);
exit (1);
}
recvfrom_nw 163