Function for finding Which process is using a port
Hi,
I am trying to find a C library routine/ sys call that would enable me to find which process is using a particular port. For example, lets sasy I want to find out which process(es) is using port# 2000 to send and receive messasges. I searched online and found that there is a function called lsof that returns values to the shell when called. But how could I do it in a C program, without having to call lsof and write its results into a file, and then scanning it. I am utilizing a TCP connection on ubuntu with gcc 4.2.3 Thanks in advance. |
Hi -
There is no such function in C (or any other language). The short answer is: "On Linux, 'lsof' uses '/proc'". But for the full story, why don't you simply look at the lsof source itself? It's freely available, and very informative. Here's one place you can get it: http://freshmeat.net/projects/lsof/ 'Hope that helps .. PSM |
All times are GMT -5. The time now is 02:32 PM. |