For a normal network programmer, the front end to the networking services of the Linux kernel are available through the following C library routines [2]:
The socket() function is used to create a new socket. All the operations with the various different protocols occur with a socket. As the routine socket() returns a file descriptor, the usual file operations can apply to it, i.e. read(), write(), etc.
The bind() function is used to tie a newly created socket to a port. The port along with the IP address of the network interface is used to uniquely identify a socket. When a socket is bound to a port, any packet that arrives with the port in its destination field is passed on to that socket controller.
The listen() function is used for server side programming. After a socket is created and bound to a port, calling the listen() function sets the socket to the listen state. This means that the socket is willing to accept connections from foreign hosts.
When the server side calls the accept() function, the program blocks and continually polls the socket until it receives a connection request from another host. Only when the connection is established is the server program woken up and allowed to process a request from the foreign host. From the client end, the connect() function is used to indicate to a server that the client wishes to open a connection to a socket and send a request.
This request is read into a string using the recv() function. The server can then use send() to send the reply to the host that requested the data.