I am trying to write C code to obtain which process is utilizing a particular port. I found that lsof does the same on the terminal. For example
lsof -i :2000 tells which pid is using port number 2000.
However, it is not a C library or a system call. How can I duplicate its functionality in a C program without calling it through system(lsof);
I am utilizing a TCP connection on ubuntu with gcc 4.2.3
Thanks in advance.