Re: Improved socket handling?

From: Date: Wed, 14 Dec 2005 13:32:34 +0000
Subject: Re: Improved socket handling?
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6384@lists.php.net to get a copy of this message
there is another way, you can use gtk :: timeout_add, it will call a function(can be from an object) every x miliseconds(seconds?) On 12/14/05, Tabber Watts <tabber.watts@gmail.com> wrote: > > Ben, > I belive you can use: > > while (gtk::events_pending()) { gtk::main_iteration(); } > > After any peice of code that you want to be updated onto the screen. > Remember that if that widget you are trying to display has just been > added to a window that has already been displayed, you need to show > that widget. Here is a quick example: > > <? > > $window = new GtkWindow(); > > $box_v = new GtkVBox(); > $window->add($box_v); > > $window->show_all(); > > $fp=fopen($usr,"r"); > while ($line = fgets($fp,1024)) { > $lbl = new GtkLabel($line); > $box_v->add($lbl); > $box_v->show_all(); > while (gtk::events_pending()) { gtk::main_iteration(); } > } > fclose($fp); > > gtk::main(); > > ?> > > I hope this helps. > > Tabber > > On 12/14/05, Benjamin Smith <lists@benjamindsmith.com> wrote: > > Is there a way to improve socket handling? > > > > For example: > > > > <? > > $fp=fopen($url, 'r'); > > while ($line=fgets($fp, 1024)) > > { > > // do something in gtk. > > } > > ?> > > > > The problem here is that the screen doesn't update while PHP is waiting > for > > data to come in from $fp. You can do somewhat better with fsockopen, but > it's > > still not a panacea. > > > > What I'm picturing is something like: > > > > <? > > $fp=fopen($url, 'r'); > > $fp->Connect('data_retrieve', 'process_data'); > > > > Function Process_Data($line) > > { > > // do something with the data in $line... > > } > > ?> > > > > > > Yeah, it's pseudo-code.Can this be done? Is there any mechanism for > doing > > this? > > > > -Ben > > -- > > "The best way to predict the future is to invent it." > > - XEROX PARC slogan, circa 1978 > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > >

« previous php.gtk.general (#6384) next »