LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-26-2009, 09:16 AM   #1
kbarani
Member
 
Registered: Dec 2008
Posts: 41

Rep: Reputation: 15
getting ports (tcp, udp) from /proc


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.

Thanks,
Barani
 
Old 03-27-2009, 04:00 AM   #2
robel
Member
 
Registered: Oct 2008
Location: Norway
Distribution: Slackware
Posts: 69

Rep: Reputation: 15
Quote:
Originally Posted by kbarani View Post
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-
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NIS server on specifc TCP/UDP ports designator Linux - Networking 5 08-19-2008 08:51 AM
What is the use of RPC "loopback" ports 32770-32789 (TCP and UDP)? bluecloud Linux - Networking 0 04-04-2008 08:46 AM
Frozen Bubble 2.1 tcp/udp Ports kule Linux - Games 1 03-05-2008 10:23 AM
Woody 3.0 Open Ports 1470/tcp/uaiact 1518/tcp/vpvd What for?How can I remove them? alexxxis Debian 5 07-05-2004 05:18 PM
how to open TCP/UDP ports RH9 franky Linux - Networking 3 07-18-2003 10:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration