what is a socket in networking

what is a socket in networking

1 year ago 93
Nature

A socket is a software structure within a network node of a computer network that serves as an endpoint for sending and receiving data across the network. It is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. Each socket has a specific address, which is composed of an IP address and a port number. The socket mechanism provides a means of inter-process communication (IPC) by establishing named contact points between which the communication takes place.

In practice, sockets are used in client-server applications. The server creates a socket, attaches it to a network port address, and then waits for the client to contact it. The client creates a socket and then attempts to connect to the server socket. When the connection is established, transfer of data takes place.

Sockets are used in many programming languages, including Java, which has a Socket class that sits on top of a platform-dependent implementation, hiding the details of any particular system from the Java program. The Java.net package includes the ServerSocket class, which implements a socket that servers can use to listen for and accept connections to clients.

Read Entire Article