Re: Socket i/o from within Gtk::main()?

From: Date: Sun, 27 Aug 2006 18:01:58 +0000
Subject: Re: Socket i/o from within Gtk::main()?
References: 1 2 3 4  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7121@lists.php.net to get a copy of this message
> It's already available. You can call Gtk::io_add_watch() or > Gtk::io_add_watch_priority() to watch a certain channel. The > interface is pretty much the same as here: > > > http://pygtk.org/pygtk2reference/gobject-functions.html#function- > gobject--io-add-watch > > As an example: > > $fp = fopen('http://www.foo.com/', 'r'); > gtk::io_add_watch($fp, Gtk::IO_IN | Gtk::IO_ERR, 'watch_foo'); > > function watch_foo($fp, $condition) > { > ... > } Excellent! I will give that a try and report back. -- Yermo > On Aug 26, 2006, at 5:35 PM, Yermo Lamers wrote: > >> >>> This is mainly due to the fact that PHP does not support multi- >>> threading, and that >>> means Gtk::main() blocks pretty much everything. >> >> There should be no reason that a single event loop shouldn't suffice, >> especially on modern hardware. >> >> In the C/C++ API this facility seems to be there, even in the single >> threaded case: >> >> http://www.gtk.org/api/2.6/glib/glib-IO-Channels.html >> >> We just need an equivalent. Provide a socket descriptor somewhere >> and have >> it be added to the main event loop .. when there's input have it >> make a >> callback. It would be plenty fast in this context. >> >> If, however, you're forced to poll a socket from a timer callback, >> then I >> can see how it would be impractical to write an IM client in PHP. >> It would >> never be fast enough. >> >> ---------------------------------------------------------------------- >> ------ >> DTLink Software >> http://www.dtlink.com >> Business and Finance Software Engineering >> ---------------------------------------------------------------------- >> ------ >> >> -- >> PHP-GTK General Mailing List (http://gtk.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > > ---------------------------------------------------------------------------- DTLink Software http://www.dtlink.com Business and Finance Software Engineering ----------------------------------------------------------------------------

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