Can anyone explain the simplest definition of what ports, sockets and processes are and what is the relationship between all 3.
Thanks in advance.
Network Engineering Stack Exchange is a question and answer site for network engineers. It only takes a minute to sign up.
Sign up to join this communityCan anyone explain the simplest definition of what ports, sockets and processes are and what is the relationship between all 3.
Thanks in advance.
An analogy may help you understand processes, sockets, ports, and their relationships.
A process is like a house and a socket is like its door. When a process wants to send a message to another process on another host (or end system: desktops, laptops, phones, etc.), the message is sent out its door (socket). When the message arrives at the destination host, it passes through the receiving process's door (socket), and the receiving process acts on the message it has received.
In short, a process sends messages into, and receives messages from, the network through a software interface called a socket. A process is a program that is running within an end system.
A port is a mechanism that allows a computer to simultaneously support multiple communication sessions with computers and programs on the network. A port directs the request to a particular service that can be found at that IP address. Think of an IP address like a street address for an apartment building, and a port (which is just a 16-bit number) as an apartment number in said building.
For a more in-depth look at ports and sockets, see: https://stackoverflow.com/questions/152457/what-is-the-difference-between-a-port-and-a-socket
Sources:
A software application running on a computer is a process.
When this application provides some kind of network service (e.g. a web server) clients need to have a way to contact this service over the network. First, they need to have the IP address of the computer to allow the network to transport data packets between the client and the server.
Now, since the computer/server can provide many different kinds of network services there needs to be a way to address the desired service on said server. For this, numbered ports are used as a kind of subaddress. Most services have a well-known port number that they usually use, e.g. TCP port 80 for the web server. The application/process is listening to new connections on its service port. Any connection or data comming on to this port is passed to the process by the operating system.
When a client wants to talk to the web server it opens a connection - a socket - between any of its own ports to the service's port on the web server's IP address. You can see this in a URL: http://192.168.1.100:80 says "open a connection to TCP (implied by HTTP) port 80 and use the HTTP protocol to fetch whatever is there". Since HTTP uses port 80 by standard the ":80" part can be omitted.