Tomcat – Why does netstat show Tomcat process listen to multiple ports

netstattomcat

The netstat output with the tomcat process(pid: 28899) is as followed:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8009            0.0.0.0:*               LISTEN      28899/java      
....
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      28899/java        
....
tcp        0      0 127.0.0.1:8005          0.0.0.0:*               LISTEN      28899/java 

So why can one process listen on three tcp ports? Is it because that 8009 and 8005 are listened by two child-processes of tomcat and netstat only display the parent process ID?

Best Answer

The short answer is "because the process asked the kernel to let it bind to three ports". There's no implicit bar on this; here's my apache, merrily listening to two ports:

[madhatta@lory mail]$ sudo netstat -apn|grep http
tcp        0      0 178.18.123.145:443          0.0.0.0:*                   LISTEN      1753/httpd          
tcp        0      0 :::80                       :::*                        LISTEN      1753/httpd