Re: Refreshing of the text
- From: John Cupitt <john cupitt ng-london org uk>
- To: mberbel wanadoo es
- Cc: gtk-list gnome org
- Subject: Re: Refreshing of the text
- Date: Wed, 14 Apr 2004 12:57:03 +0000
Hi Marc,
mberbel wanadoo es wrote:
I'm using GTK and libpcap (library dedicated to provide routines for 
packet caputre) to make a sniffer with GUI in C. I have a problem, when 
I start to sniff, the program comes into a function from which will get 
out in the moment that a certain number of packets are sniffed.
In that function, I write in a window the content of every packet. The 
problem is that if I want to sniff 1000 packets, all the text will 
become visible once the 1000 packets are visible, and not ever time a 
packet is received.
Is there any way to modify this ?? I would like to show the text every 
time that I get a packet.
You have two solutions, I think:
- Every time a packet comes in, update your widgets and call
   while( g_main_context_iteration( NULL, FALSE ) )
     ;
 this will make the screen repaint.
 Of course you may drop packets while you do this, since the 
 repaint will take some time. Also you will need to be careful
 that buttons cannot be clicked twice, since you will then have
 two main loops.
- Make a background thread to do the sniffing with g_thread_create(). Make
 a pipe, and have the background thread write its results to the pipe.
 Do gtk_input_add_full() to make your foreground thread wake up when things
 are written to the pipe. When stuff arrives, update the screen.
John
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]