Re: Perl, GTK, Network
- From: "muppet" <scott asofyet org>
- To: gtk-perl-list gnome org
- Subject: Re: Perl, GTK, Network
- Date: Fri, 12 Dec 2003 11:56:29 -0500 (EST)
Mark Lehrer said:
What is the best strategy for handling the network in Gtk? Is there a
way to attach some kind of gtk signal handler to incoming network
traffic, or is it better to use some kind of threading?
use Glib::IO->add_watch to watch a file descriptor for input in the main loop:
http://gtk2-perl.sourceforge.net/doc/pod/Glib/MainLoop.html#integer_Glib_IO_add_
here's the GLib function that this wraps:
http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html#g-io-add-watch
and a Gtk2::Helper method exists to make that easier to use:
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/Helper.html
basically, the idea is that you have the main loop watch the file descriptor
for input, and tell the mainloop to call some function when there is input
available.
this is a frequently asked question, but doesn't seem to appear in the gtk
faq... it's been asked before:
http://mail.gnome.org/archives/gtk-list/1998-March/msg00608.html
--
muppet <scott at asofyet dot org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]