Learn something new every day
More Info... by email
A TCP/IP socket is used for communications between two computers. The socket includes the Internet protocol (IP) address, as well as the host or port that the computers are using to transmit the data. All applications that take part in the transmission use the socket to send and receive information.
The purpose of a TCP/IP socket is to identify the computer or network server's unique IP address, along with its port number. Port numbers are sometimes referred to as hosts, and they tell the receiving computer where to send the requested data. Together, the IP address and port number make up a socket.
A port address is the number of the port that will be used to send and receive data. Each computer device has several different ports that it uses to send and receive communications. Since some of those ports may be used by certain devices such as printers, the computer needs to tell other devices where to send information. In Internet communication, the port may be an Ethernet port assigned to a specific device or the port address of a server that is connected to several individual computers.
A computer socket, including a TCP/IP socket, is used to facilitate communication between two separate devices. It provides instructions for where that communication should be sent. The IP address and port address contained in the TCP/IP socket tells the receiving computer where to send the requested data. It also helps establish some sort of uniform language between the machines.
When a socket is created, the sender and receiver both test the communication port to ensure that the data is going through. The sender may send a request that tells the receiver what its identity is. A response is then sent back to the sender confirming the sender's identity, while also communicating the identity of the receiver. As long as the communications go through and the socket is confirmed to be working, further data requests continue.
Sockets are created each time a communication protocol is established between two or more devices. Once the communication process has ended, the TCP/IP socket is closed. If for some reason the port requested is not available, the socket will not be created. An error message will usually prompt both the sender and receiver that the socket has failed.
Applications that are used in communications, including web browsers, also use TCP/IP sockets to send and receive data. During the time that the socket is in use, all communications and applications are bound to the port address that is identified in the socket. As applications send and receive data, they look for the socket's specific port address or host.