Socket is a software module that allows a computer program with a computer network to exchange data and connect with other computers. Sockets are also used to switch between processes on the same computer to send data. The communication via socket is usually bi-directional, socket can be both receive and send data.
Operation of Socket
Socket provide a platform-independent, standardized interface ( API ) between the network protocol – implementation of the operating system and the actual application software. A computer program called a socket on the operating system. The operating system is responsible for use of socket and their associated connection information to manage.
Stream socket is to communicate over a symbol – stream , datagram sockets on individual messages. Use in network communication stream sockets usually TCP , datagram sockets usually UDP . TCP is a reliable UDP for many tasks more efficiently and flexibly, often faster (in time).
A server can either wait for requests from a particular address or it will listen on all addresses on its computer. There are some protocols, a so-called wild-address, wherein one or more parts of the address information is not specific. In Linux, this wildcard address 0.0.0.0
When the server receives a request from a client that is derived from the listening to server socket that standing together with server socket : the original server socket remains and continues to wait for new connections, while a new socket opens on the particular client for communication. This remains in effect until the connection to the client of one of the two sides will be terminated.
Usage of Socket in various operating systems
Unix and Unix-like operating systems use BSD socket for network communication. For local interprocess communication they use so-called UNIX domain socket can be a simple way to communicate. Windows uses the BSD sockets modeled on so-called Windows Sockets API (Winsock).