Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
A socket is a software object that acts as an end point establishing a bidirectional network communication link between a server-side and a client-side program.
In UNIX, a socket can also be referred to as an endpoint for interprocess communication(IPC) within the operating system(OS).
In Java, socket classes represent the communication between client and server programs. Socket classes handle client-side communication, and server socket classes handle server-side communication.
Mostly URLs and their connections are used to access the Internet, but sometimes programs require a simple communication link between the program’s client and server side. This role would be associated to a socket which would tie the program's client and server sides.
When a client establishes communication with the server, for example by querying the database, a reliable server and client connection is established via a TCP communication channel. In this type of communication, the client and server can read or write on sockets tied to specific communication channel.
Sockets are mainly classified into two types: active and passive. Active sockets are connected with the remote active sockets through an open data connection. If this connection is closed, the active sockets at each end point is destroyed. Passive sockets are not connected; instead, they wait for an incoming connection that will spawn a new active socket.
Even though there exists a close relationship between a socket and a port, the socket is not actually a port. Every port may have a single passive socket waiting for incoming connections and several active sockets each respective to an open connection in the port.