IPX/SPX Programming Manual

Library Routines
HP NonStop IPX/SPX Programming Manual528022-001
5-39
recvfrom_nw
Example
In the following 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 <nv.h>
#include <netdb.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
...
struct sockaddr_nv fhost;
int buffsize,len,rsock;
char buffer [8*1024];
short error, rsock2;
long tag;
...
buffsize = sizeof(buffer);
error = recvfrom_nw(rsock,buffer,buffsize,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);