One method is to use procfs :
Open /proc/net/tcp and sscanf on it.
The first line is the header, st being the state, local_address is of the form ip_in_hex:port_in_hex.
ESTABLISHED=1
SYN_SENT=2
SYN_RECV=3
FIN_WAIT1=4
FIN_WAIT2=5
TIME_WAIT=6
CLOSE=7
CLOSE_WAIT=8
LAST_ACK=9
LISTEN=10
CLOSING=11
Should be sufficient..
Last edited by nx5000; 06-23-2006 at 01:58 AM.
|