What is a Network Socket? (Computer Networks)

Computer NetworkInternetMCA

A network socket is a software component within a computer network node that acts as an endpoint for delivering and receiving data. An application programming interface (API) for the networking architecture defines the structure and properties of a socket. Sockets are only produced over the lifespan of a process in a node-based application.

Because the TCP/IP protocols were standardized during the creation of the Internet, the word "network socket" is most often used in the context of the Internet Protocol suite, and it is hence referred to as an "Internet Socket". In this context, a socket's address, which is the triad of the transport protocol, IP address, and port number, is used to externally identify it to other hosts.

The software endpoint of node-internal inter-process communication (IPC), which frequently utilizes the same API as a network socket, is often referred to as a socket.

Pipes are formed using the 'Pipe' system call, and sockets are generated with the 'socket' system call. Over the network, the socket allows bidirectional FIFO communication. At either end of the connection, a socket connecting to the network is formed. Each socket has its unique address. An IP address plus a port number make up this address.

In most client-server applications, sockets are used. The server builds a socket, connects it to a network port, and waits for the client to connect to it. After creating a socket, the client tries to connect to the server socket. Data is transferred after the link is established.

Types of Sockets

Datagram Socket − A datagram socket is a type of network socket in which packets are sent and received without the use of a link. It resembles a mailbox. Letters (data) are gathered and delivered (transmitted) to a mailbox (receiving socket). It is a connection-less socket.

Stream Socket − A stream socket is a type of network socket in a computer operating system that provides a connection-oriented, sequenced, and unique flow of data without record boundaries, as well as well-defined mechanisms for creating and destroying connections and detecting errors. It is comparable to a telephone. Between the phones (two ends), a link is created.

The following diagram shows the complete Client and Server interaction −

Function CallDescription
create()To construct a socket
bind()It's a socket identifier, similar to a phone number for contacting someone.
connect()Are you ready to make a connection?
listen()Prepared to send a message
accept()Confirmation is similar to accepting a call from a sender.
write()To send data
read()To receive data
close()To make a relationship permanent
Updated on 17-Aug-2021 14:00:34