Functions to get which process is utilizing a particular port

This is a discussion on Functions to get which process is utilizing a particular port within the C Programming forums, part of the General Programming Boards category; Hi, I am trying to write C code to obtain which process is utilizing a particular port. I found that ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    19

    Functions to get which process is utilizing a particular port

    Hi,

    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.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    You sure can. Google sockets. Its a little more work than you may be thinking it will be, but it isn't THAT much work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An array of macro functions?
    By someprogr in forum C Programming
    Replies: 6
    Last Post: 01-28-2009, 06:05 PM
  2. Reading and writing to a serial port
    By SwarfEye in forum C Programming
    Replies: 2
    Last Post: 08-18-2006, 12:28 AM
  3. Segmentation Fault - Trying to access parallel port
    By tvsinesperanto in forum C Programming
    Replies: 3
    Last Post: 05-24-2006, 03:28 AM
  4. C functions to access USB port.
    By nethunter in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-10-2006, 02:25 PM
  5. Replies: 12
    Last Post: 05-17-2003, 05:58 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21