
Compilation
obsd32# cc -o udp1 udp1.c
Example Execution
obsd32# ./udp1
socket() success.
udp1.c is a simple program that attempts to create a UDP socket.
Analysis
■
At line 11 and 12, the sys/socket.h and netinet/in.h header files are included.
These files contain the function prototypes and data structures required to use
the socket() function.
■
At line 19, the socket() function is called.The first parameter is the integer con-
stant AF_INET (defined in sys/socket.h).This constant indicates that the socket
is of the AF_INET address family.The AF_INET address family indicates
usage of IPv4 addressing.
■
The second parameter passed to the socket() function is the ...