Results 1 to 7 of 7
Hi all,
I am programming on Linux middleware so I need to get a list of all active TCP connections. Is there any API to get such information? I know ...
- 10-19-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 7
How to find the active TCP connections and PIDs corresponding to them?
Hi all,
I am programming on Linux middleware so I need to get a list of all active TCP connections. Is there any API to get such information? I know I can find the connections in /proc/net/tcp, but how to find the PIDs? Apparently ps or netstat command is not an option since it is a middleware. Any help will be appreciated!
Cheers
Tete
- 10-19-2010 #2
Hi and welcome
As root
Also this might helpCode:netstat -anp --ip

Code:man netstat
You must always face the curtain with a bow.
- 10-19-2010 #3Just Joined!
- Join Date
- Oct 2010
- Posts
- 7
Thanks for the quick reply. But as I said, if it is a program, is it a little bit ugly to use system("netstat -any --ip") in the program? Is there any library or function to call to do the same job? Or actually I am new to linux programming so I don't really know how they usually do it? Just this system call? Thanks again!
- 10-19-2010 #4
Sorry, missed that part.
I am not a dev, but from the look of the man page and also a quick strace, netstat actually parses /proc.
From the top of my head, I am not aware of a library or API, but maybe someone else here has an idea.You must always face the curtain with a bow.
- 10-19-2010 #5
There is a perl module
Linux::Proc::Net::TCP - search.cpan.org
Which language are you using?You must always face the curtain with a bow.
- 10-19-2010 #6Just Joined!
- Join Date
- Oct 2010
- Posts
- 7
- 10-19-2010 #7
hmm,
as you know C, a look into netstat´s code might provide more insight.
Index of /phil/net-tools/
Disclaimer:
This is GPL2 software, so be careful to actually re-implement, not copy, if your licence is not GPL2.You must always face the curtain with a bow.


Reply With Quote
