Socket

A socket is known as a type of software that acts as an endpoint that functions in establishing a bidirectional network communication link between the server's end and the receiving program of the client.[1] It is also often referred to as one endpoint in a two-way communication channel. These sockets are made and mobilized together with a set of programming requests that are identified as the function calls, which is technically termed as the application programming interface (API). A socket is able to simplify how a program functions because programmers now only have to worry about manipulating the socket functions and this allows them to rely on the operating system to actually transport the messages across the network correctly.[2]

Functionality

Typically, a socket abides by a specific flow of events for it to work. For a connection-oriented client-to-server model, the socket on the server process waits for the request from a client. In order to make this, the server needs to primarily establish an address that the clients can use to find and connect to the server. When a connection is successfully established, the server will wait for the clients to request a service. The client-to-server data exchange will take place if the client will connect to the server through the socket. The server will then answer the client's request and send a reply.[3]

Most of the time, URLs and their connections are used in order to access the internet. Programs will require a simple communication link between the program’s client and server side. This role is associated with a socket that will help tie the program’s client and server ends. If a client starts to establish communication with the server, a reliable server and client connection will be made through the TCP communication channel. With this type of communication, both the client and server can read or write on sockets that are tied to a specific communication channel.[^04]

Types of Sockets

The following are different types of sockets:

Datagram Sockets

This is a type of network socket that provides a connection-less point for sending and receiving data packets. Every packet that is sent from a datagram socket is individually routed and delivered. It can also be used for sending and receiving broadcast messages.

Raw Sockets

This socket allows access to the underlying transport provider. These are able to provide the users with access to the underlying communication protocols that support socket abstractions. Normally, these are datagram oriented even though their exact characteristics are dependent on the interface provided by the protocol. These are not intended for general use but they have been provided mainly for those who are interested in developing new communication protocols or use for gaining access to some cryptic facilities of protocols that already exist.

Sequenced packet Sockets

This is similar to a stream socket, however, with the exception that record boundaries are preserved. This type of socket allows the users to manipulate the sequence packet protocol (SPP) or the internet datagram protocol (IDP) headers on a packet or even a group of packets. This socket also allows the user to receive headers for incoming packets.

Stream Sockets

This type of socket relies on TCP to transmit data. If the delivery of data is impossible, the sender will receive an indicator that the connection resulted in an error. The data records do not have any boundaries.[4] This socket provides a connection-oriented, sequenced, and unique flow of the data without record boundaries, with well-defined mechanisms for creating and/or destroying connections and for detecting errors. It transmits reliable data, in order and without out-of-band capabilities. Processes are presumed to communicate only between sockets of the same type but there is no restriction that prevents communication between these sockets of different types.

Active socket

This is a socket connection with the remote active sockets through an open data connection. It this connection will be closed, the active sockets at each point will also be destroyed. This is used by the clients who would like to initiate connection requests to connect. However, this active socket can also be transformed into a passive socket through binding a name to the socket with the bind-macro and by indicating a willingness to accept connections with the listen-macro.

Passive socket

This socket is not connected but, instead, waits for an incoming connection that will spawn a new active socket. This is used by the servers in order to accept connection requests with the connect-macro. This passive socket cannot be used for initiating connection requests. The concepts of active and passive sockets for stream sockets do not apply to the other types of sockets, such as the datagram socket.[5]

Ports and Sockets

A socket is an interface for sending and receiving data on a specific port while a port is a numerical value assigned to a specific process or an application in the device.[6] Even though there is a close relationship between a socket and a port, the socket is not actually a port. Each port may have a single passive socket waiting for the incoming connections and several active sockets each respective to an open connection in the port.[1:1] Nowadays, the socket makes communication easier and more efficient. It allows the establishment of a connection between two different processes on the same or different machines. Simply put, it is a way to talk to another computer.

History

The use of the term "Socket" started in 1971 where it was used during the development of ARPANET. Most of the sockets implemented today are based on Berkerley sockets, which were developed in 1983. Sockets used to establish an internet connection, however, are modeled after the Winsock models that were made in 1991. Berkerley sockets are also known as the BSD socket. In 1989, Berkerley released versions of its operating system and their networking library as free from licensing constraints. Other early implementations were written for TOPS-20, MVS, VM, and IBM-DOS.


  1. https://www.techopedia.com/definition/16208/socket ↩︎ ↩︎

  2. https://www.webopedia.com/TERM/S/socket.html ↩︎

  3. https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/rzab6/howdosockets.htm ↩︎

  4. https://www.tutorialspoint.com/unix_sockets/what_is_socket.htm ↩︎

  5. https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.hala001/astream.htm ↩︎

  6. http://pediaa.com/difference-between-socket-and-port/ ↩︎