Creating A Socket When a socket is created, we need to tell it what type of address family it should use, what type of protocol family and what type of protocol in that family. All this is done using the 'socket' system call: #include /* basic data types. */ #include /* socket syscalls/constants. */ int s; /* stores the file descriptor of the socket. */ /* allocate a free socket */ /* Internet address family, Stream socket */ s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { perror("socket: allocation failed"); }