Quote:
Originally Posted by kbarani
Hi all,
How to get the list of TCP , UDP ports running in the linux machine
from /proc/net/tcp ,/proc/net/udp through C program. Anyone have this program pls send me.
|
I do not have a program, but you can check out the source for netstat
http://www.tazenda.demon.co.uk/phil/net-tools/
It's a matter of sscanf() I guess.
Code:
num = sscanf(line,
"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %ld %512s\n",
&d, local_addr, &local_port,
rem_addr, &rem_port, &state,
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode, more);
This code is from netstat.c around line 720
-Bob-