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 ...
- 10-31-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 6
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
- 10-31-2007 #2
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:
Then parse that information with your program.Code:netstat -a --numeric -e -p
For less information, play with the options to the netstat command.
For more information on the netstat command, do this at the command line:
Hope this helps.Code:man netstat
- 10-31-2007 #3Just 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
- 10-31-2007 #4
In what language are you writing this program?
- 10-31-2007 #5Just 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.
- 10-31-2007 #6
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


Reply With Quote