tags:

views:

182

answers:

2

Is there an API call on Linux which returns currently opened TCP connections on the system (like GetTcpTable call on Windows)?

Thanks.

+3  A: 

As per UNIX philosophy of "everything is a file", you can get what you want from reading /proc/net/tcp.

andri
That was fast :) Thanks
"netstat -t" from the command line (or through an exec) also works.
Matt J
..but doesn't do quite the same thing :)
Matt J
Netstat reads the same file anyway, so you might as well go directly to the source.
andri
+1  A: 

You should check out netstat -t (for TCP). Man netstat will give you all the options.

Joe
Whoops, other people already commented about this. Well, you should really check it out.
Joe
Heh, it happens :)
No worries :) I only did it as a comment because /proc/net/tcp seems more straightforward for checking connections programmatically.
Matt J