Re: traffic counter in C
- From: guilherme.oliveira@xxxxxxxxx
- Date: 31 May 2006 09:20:16 -0700
Hi again.
I'm trying to do something with netstat but it's giving segmentation
fault (core dumped):
#include <stdio.h>
#include <unistd.h>
void recv()
{
#define LINE_LENGTH 500
char output_recv[LINE_LENGTH];
FILE *grab_recv;
/* exec netstat -s */
execl("/usr/bin/netstat -s -p tcp", "", grab_recv);
/* grab the result */
fgets(output_recv, LINE_LENGTH, grab_recv);
pclose(grab_recv);
/* print the result */
sprintf (output_recv, "Recebidos %s bytes ", output_recv);
puts(output_recv);
}
main ()
{
/* exec recv() to know received traffic */
recv();
}
/* EOF */
guilherme.oliveira@xxxxxxxxx escreveu:
Hi !
I want to do a traffic counter in C for FreeBSD.
I have already done the daemon with forks but don't know where to get
the value of transfered data becayse these value isn't in '/proc'
(empty) or 'sysctl -a'
Any ideas ?
.
- Follow-Ups:
- Re: traffic counter in C
- From: moi
- Re: traffic counter in C
- References:
- traffic counter in C
- From: guilherme . oliveira
- traffic counter in C
- Prev by Date: Re: Child process IDs
- Next by Date: Re: traffic counter in C
- Previous by thread: traffic counter in C
- Next by thread: Re: traffic counter in C
- Index(es):
Relevant Pages
|