06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

pNA+ <strong>System</strong> <strong>Calls</strong> recvfrom<br />

MSG_RAWMEM Specifies that you have set buf to point to a<br />

linked list of mblks and len to the total size of<br />

the message.<br />

MSG_INTERFACE Specifies that you want the interface number of<br />

the NI on which the packet arrived to be stored<br />

in from.<br />

from If from is not a NULL pointer, recvfrom() fills in the<br />

sockaddr_in structure it points to with the address of the<br />

received data's sender.<br />

The structure sockaddr_in is defined in and has the<br />

following format:<br />

struct sockaddr_in {<br />

short sin_family; /* must be AF_INET */<br />

unsigned short sin_port; /* 16-bit port number */<br />

struct in_addr sin_addr; /* 32-bit IP address */<br />

char sin_zero[8]; /* must be 0 */<br />

};<br />

This structure cannot be packed.<br />

If flags includes the MSG_INTERFACE constant, then the structure<br />

pointed to by from is filled with the structure<br />

sockaddr_intf. This is supported only for datagram sockets.<br />

This feature is useful with unnumbered links where it may not be<br />

clear which interface the packet arrived on.<br />

The structure sockaddr_intf is defined in and has the<br />

following format:<br />

struct sockaddr_intf {<br />

short sin_family; /* must be AF_INET */<br />

unsigned short sin_port; /* 16-bit port number */<br />

struct in_addr sin_addr; /* 32-bit IP address */<br />

long sin_ifno; /* 32-bit interface number */<br />

char sin_zero[4]; /* must be 0 */<br />

};<br />

The field sin_ifno identifies the interface number of the incoming<br />

message's receiving interface.<br />

fromlen An input-output parameter. On input, it should point to an integer<br />

equal to 16, which is the size in bytes of both struct<br />

sockaddr_in and struct sockaddr_intf.<br />

<strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong> 4-49<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!