April 2002
Intermediate to advanced
1024 pages
23h 26m
English
Two types of sockets are in general use: TCP sockets and UDP sockets (SOCK_STREAM and SOCK_DGRAM respectively). A “raw” socket is also available that is used for specialized applications such as “ping” and “traceroute” (tracert).
In the beginning, the network programmer had to deal with the structures in Listing 12.1 just to establish a connection.
struct sockaddr { unsigned short sa_family; // address family, AF_xxx char sa_data[14]; // 14 bytes of protocol address }; struct sockaddr_in { short int sin_family; // Address family unsigned short int sin_port; // Port number struct in_addr sin_addr; // Internet address unsigned char sin_zero[8]; // Same size as struct sockaddr } ; struct ... |