Reputation: 522
The netstat(8)
man page states "Show both listening and non-listening (for TCP this means established connections) sockets. With the --interfaces option, show interfaces that are not marked"
What is a non-listening socket vs a listening socket? Does it still occupy the port? or is the port free to be used by other programs?
Upvotes: 5
Views: 2182
Reputation: 3782
Sockets run a state machine. They wait, then respond to requests. One of the states is 'LISTEN'.
Non-listening is every other state, in other words when something is happening or a connection is established.
There's a good TCP state diagram with state descriptions here. I've provided a reduced size version here, in-case the link ever breaks.
Upvotes: 7
Reputation: 22254
A listening socket is one where the server process is waiting for someone to connect to it, for example, an idle web server. The port it is listening on is considered in use.
A non-listening socket is one where a connection has been made, for example, a web server where a web client, such as a browser, has connected, and data can be or is being transmitted. The port the socket was listening on is usually then also cycled back to be listened on by the same process or process tree.
Upvotes: 5