Networking Forums

Networking Forums > Computer Networking > Linux Networking > socket programming

Reply
Thread Tools Display Modes

socket programming

 
 
rak.dontmess@gmail.com
Guest
Posts: n/a

 
      02-12-2008, 06:09 PM
hello ... this is rakesh ..... i am new to socket programming ..... i
just want to know wheather if we could get statistics related to a
particular port using socket programming in C? statistics in the
sense .... no of packets transmitted,received etc ..... or is there
any file in linux( i use fedora) which gives this kind of
information? .... thanks in advance !!!
 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a

 
      02-12-2008, 06:53 PM
On Feb 12, 2:09 pm, rak.dontm...@gmail.com wrote:
> hello ... this is rakesh ..... i am new to socket programming ..... i
> just want to know wheather if we could get statistics related to a
> particular port using socket programming in C? statistics in the
> sense .... no of packets transmitted,received etc ..... or is there
> any file in linux( i use fedora) which gives this kind of
> information? .... thanks in advance !!!


Why not use the "/sbin/ifconfig" file? As in...

struct FILE *Stats = popen("/sbin/ifconfig eth0","r");

if (Stats)
{
char buff[256];

while (fgets(buff, sizeof(buff), Stats) != EOF)
fputs(buff,stdout);
pclose(Stats);
}
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      02-12-2008, 09:13 PM
(E-Mail Removed) wrote:
> hello ... this is rakesh ..... i am new to socket programming
> ..... i just want to know wheather if we could get statistics
> related to a particular port using socket programming in C?
> statistics in the sense .... no of packets transmitted,received etc
> ..... or is there any file in linux( i use fedora) which gives this
> kind of information? .... thanks in advance !!!


The closest you can get IIRC is what is reported by a TCP_INFO
getsockopt(), which is described in the manpage for tcp under linux.
It is decidedly non-portable. That of course won't do anything for
UDP, or DCCP or SCTP etc etc. And it is very specific to the Linux
stack - it may not be there on other stacks.

There might be some way using netfilter (?) to gather those stats, but
I'm not sufficiently familiar with how one uses that to say.

rick jones
--
portable adj, code that compiles under more than one compiler
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      02-12-2008, 09:14 PM
Lew Pitcher <(E-Mail Removed)> wrote:
> On Feb 12, 2:09 pm, rak.dontm...@gmail.com wrote:
> > hello ... this is rakesh ..... i am new to socket programming ..... i
> > just want to know wheather if we could get statistics related to a
> > particular port using socket programming in C? statistics in the
> > sense .... no of packets transmitted,received etc ..... or is there
> > any file in linux( i use fedora) which gives this kind of
> > information? .... thanks in advance !!!


> Why not use the "/sbin/ifconfig" file? As in...


> struct FILE *Stats = popen("/sbin/ifconfig eth0","r");


> if (Stats)
> {
> char buff[256];


> while (fgets(buff, sizeof(buff), Stats) != EOF)
> fputs(buff,stdout);
> pclose(Stats);
> }


That would give the count of everything that went through the
interface, not just that for the OP's port of interest. Now, if he
"knew" that his was the only active sockets application using that
interface it would give him what he wants, but I doubt that will ever
be the case.

rick jones
--
web2.0 n, the dot.com reunion tour...
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      02-12-2008, 11:00 PM
On Feb 12, 11:09 am, rak.dontm...@gmail.com wrote:
> hello ... this is rakesh ..... i am new to socket programming ..... i
> just want to know wheather if we could get statistics related to a
> particular port using socket programming in C? statistics in the
> sense .... no of packets transmitted,received etc ..... or is there
> any file in linux( i use fedora) which gives this kind of
> information? .... thanks in advance !!!


This is one thing I really like about FreeBSD and really miss about
Linux. FreeBSD has some great ways to track flows passing through it
and track traffic by destination and by port.

I know of no good ways to do this on Linux. I would be very interested
in possible ways to do this because I have been forced to use FreeBSD
for several firewalls where I would prefer Linux because I can't get
good statistics on traffic by destination host and/or by flow.

HTB also can't easily regulate traffic by host unless you reserve
bandwidth for every single host. That's awkward when you have tens of
thousands of hosts.

DS
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
applications possible with help of socket programming addy Windows Networking 0 10-17-2007 10:34 AM
vlan in socket programming sl Linux Networking 0 05-29-2005 08:22 AM
Can any one help me!! (Socket Programming) girishdomain@gmail.com Linux Networking 8 05-25-2005 04:17 PM
socket programming Andreas Lassmann Linux Networking 4 04-27-2005 06:52 AM
socket programming PH Linux Networking 4 11-16-2003 10:39 PM



1 2 3 4 5 6 7 8 9 10 11