Client socket
In computer science, a client socket is a feature of the operating system for establishing networked computer communication between a server computer and client computer, initiated by the client. A client socket forms one endpoint in a client–server socket relationship.
For instance, if you type ibm.com into your browser, it is converted into the IP address 129.42.16.103 (or whatever). The browser then creates a client socket, because it wants to talk to this computer. It sets the destination address to 129.42.16.103, and the port to 80 (that's http). The socket then reaches across the internet, finds the computer system numbered 129.42.16.103, and sends a message to port 80 (the server socket), usually something like "GET /", which roughly means, "give me your front page HTML text". That computer then sends the text, as commanded, to the client socket. The browser then figures out how to display the HTML, after destroying the client socket. Each image, for instance, is a file that must be retrieved with another transaction as above, involving another client socket being created just for that file.
The client socket is always the one who initiates the connection. Usually, this is the side closest to the human - your laptop or workstation. Sending Email only happens when the client program decides to send; it then sends to the server using SMTP. Retrieving email likewise only happens when the client program decides to check mail; it sends a request to the server using POP3 or IMAP protocol. Even Peer-to-Peer or server-to-server communications define a client and server based upon who starts the conversation, even though they may often trade roles.
The client side must find the server through a Well-known port, whereas the client port number changes for each incarnation; this is called a Ephemeral port. This is a natual part of the process, as the server port must be easy to find, but the client port should be difficult to find to avoid certain kinds of hacker attacks. This is analogous to an anonymous shopper finding a well-known store.
Operation
Following inception, a client socket assists in handling lower-level network functions by forming and sending a request to a waiting server, which then processes the received data. Usually, but not always, the client socket will also listen for and receive a reply from the server pertaining to the data the server received immediately prior. Both client and server sockets are required in a functional socket-based connection. Unlike their server socket counterparts, client sockets are often used for single data exchanges and more suited for such than server sockets are. [1].
See also
References
- ^ Kuchling, Andrew. http://www.amk.ca/python/howto/sockets/ Socket Programming HOWTO. Retrieved on 2008-09-29