Loading...
Select Version
&pagelevel(4)&pagelevel
With AF_INET, name comprises an IPv4 address and a port number. name is passed in a variable of type struct sockaddr_in (see "sockaddr_in address structure of the AF_INET address family ").
The following program extract illustrates how a name is assigned to a socket.
#include <sys/types.h> #include <netinet/in.h> ... struct sockaddr_in sin; ... /* The statements which supply "sin" with an Internet address and a port number must be inserted here.*/ ... bind(s, (struct sockaddr *)&sin, sizeof sin);