# Do programs such as ssh or ftp really listen on ports?



## clawhammer (Apr 1, 2018)

Ive been reading about ports and its always described as http listens on port 80 or telnet listens on port 23. Is this an accurate description or whats really going on? For some reason it feels like an easy way to describe it. I would assume the nic card gets all the traffic and each network daemon has a PID and the nic uses that to send info to a particular program. Is the program really listening or is it just waiting for input from the nic card to be sent to it as it would a data file? Do ports really exist?


----------



## ShelLuser (Apr 1, 2018)

Just see `sockstat -l`. It's definitely accurate because it's exactly what is happening. The daemon basically opens / registers a socket after which the OS will know that whenever traffic enters for that socket it should sent that data to the listening daemon. Daemons quite literally wait while listening for incoming data to process.

Obviously there is more going on such as the NIC receiving the data, that is explained with the OSI model.

If you want to learn more about the inner working then chapter 7 of the developers handbook might be an interesting read.


----------



## clawhammer (Apr 2, 2018)

ShelLuser said:


> Just see `sockstat -l`. It's definitely accurate because it's exactly what is happening. The daemon basically opens / registers a socket after which the OS will know that whenever traffic enters for that socket it should sent that data to the listening daemon. Daemons quite literally wait while listening for incoming data to process.
> 
> Obviously there is more going on such as the NIC receiving the data, that is explained with the OSI model.
> 
> If you want to learn more about the inner working then chapter 7 of the developers handbook might be an interesting read.


thanks, Im going through some of the handbook now and I got some freebsd books. I understand things when I read them and then I read more and get confused about how everything works together. It just seems like there is so much going on.


----------

