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.