0

Can anyone explain the simplest definition of what ports, sockets and processes are and what is the relationship between all 3.

Thanks in advance.

closed as off-topic by Ron Maupin Apr 1 '18 at 22:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "NE is a site for to ask and provide answers about professionally managed networks in a business environment. Your question falls outside the areas our community decided are on topic. Please visit the help center for more details. If you disagree with this closure, please ask on Network Engineering Meta." – Ron Maupin
If this question can be reworded to fit the rules in the help center, please edit the question.

  • It sounds like you are asking about programming, but that would be off-topic here. You can ask about that on Stack Overflow where there are many network-savvy programmers. Otherwise, you would need to specify the network protocol about which you are asking. – Ron Maupin Mar 4 '18 at 17:31
2

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:

  1. Computer Networking: A Top-Down Approach by James Kurose and Keith Ross
  2. Data Communications and Networking by Behrouz Forouzan
  3. https://technet.microsoft.com/en-us/library/cc959834.aspx
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.