Find the answer to your Linux question:
Results 1 to 6 of 6
hi, say i have a system connected to another system in a network. and the remote system queries me for all open socket lists, local address of the connection and ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    6

    Question socket list

    hi,

    say i have a system connected to another system in a network. and the remote system queries me for all open socket lists, local address of the connection and remote address of the connection. how can i get these information through a program considering that i have to generate the information onmy machine and send to the remote machine. also my machine is connected to other systems in a network.

    any suggestions are most welcome.


    sanjay

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    There are several ways to do this. The easiest way is to have your program run this command and send the output to a file:
    Code:
    netstat -a --numeric -e -p
    Then parse that information with your program.

    For less information, play with the options to the netstat command.

    For more information on the netstat command, do this at the command line:
    Code:
    man netstat
    Hope this helps.

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    6

    re:

    yeah i know the way, but i don't want to create a temporary file at my system and want to manage with buffers or some other way. exactly i want the protocol name, local address and remote address of the connection from the output of netstat. in RHEL netstat -nap shows all the statistics. tell me the other ways...

    thanks for the reply..
    sanjay

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    In what language are you writing this program?

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Posts
    6

    re:

    i am going to write that program in C or C++.but C will be fine also.
    waiting for yopur reply.

  6. #6
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    The easiest way to read the output of the netstat command without using a scratch file is to use popen(). If you're doing this more than once, don't forget pclose().

    Do this at the command line and all will be revealed.
    Code:
    man popen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...