I know there will be multiple ports in the host/computing machine for each of the services that i hosts on the network.

But i want to understand what are these ports internally?

Below is my understanding of network ports. Correct me if i am wrong. Add details to make it more clear.

They might be a software construct, mostly a queue/buffer inside the networking component of OS, created dynamically whenever a network service (Web service, file transfer service, etc.) is hosted on the machine. And each of the network service would be listening to their respectively port (to receive the data) and also has access to write it that port (to send the data). [Just like a bounded buffer problem]

When data needs to be sent-
The network service (Application) would make a system call to OS (say, send()) to write the data onto the buffer and inform the transport protocol. So that the TCP/UDP protocol would take the data from the buffer and segment it and pass it down the network stack.

When data needs to be received-
As the data arrives to the host through the NIC, data would be read from some low level network component in the OS and passed up the network stack. And when the transport layer component of OS reads it, it puts the data on the queue associated with that particular port no. so that the application (network service) listening to that port can read the data.

closed as unclear what you're asking by Ramhound, n8te, bertieb, djsmiley2k, G-Man Apr 2 '18 at 6:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Almost, but not entirely correct.

  • Sockets are the software construct with buffers (each socket has separate send & receive queues). For TCP, each connection uses a separate socket.

  • Ports are only numeric labels used for demultiplexing – helping the OS choose which socket (or which receive buffer) should receive an incoming packet.

Each socket is associated with multiple parameters – protocol, local & remote addresses, and local & remote ports – and all of them are used when looking up a received packet. (When the addresses are identical, at least one of the ports must be different. But if the addresses are different, then multiple sockets can use identical ports.)

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