Interview Questions

What is the life cycle of a socket communication?

Perl, Sockets and TCP/IP Networking


(Continued from previous question...)

What is the life cycle of a socket communication?

Let's look briefly at the normal sequence of operations for Internet communication. The server first establishes a socket with the socket function, which returns a socket descriptor much like a file descriptor. The server next assigns the socket an address with bind, then tells the system that it is willing to receive connections with the listen function. The accept function can block until a client connects to the server. The client program also calls socket and gets a socket descriptor. The client connects to the address specified by the server's bind call using the connect function. If all goes well, the client can read and write to the socket descriptor just as if it were a file descriptor.

(Continued on next question...)

Other Interview Questions