[Glade-users] Glade and sockets



Aaron Smith wrote:

After creating the initial window, my glade app calls
a gtk_main function that I don't the source for.  This is
presumably an event loop which waits for gui events and
calls the appropriate handlers.  The problem is that I'd like
to create a networked app which must respond not only to
gui events, but also to incoming messages on a socket.
Is there a way to register a socket ready event so that
gtk_main will capture it?  Or is there some other way to
poll a socket periodically within the event loop?

Well, this is really a gtk+ question but never mind...

If you want to process incoming data in the gtk+ event loop then create
the socket (or pipe etc) and use gdk_input_add() to "attach" it to the
event system.

For polling, use gtk_timeout_add().

There is a library called gnet (I think) which might be useful here.
IIRC it does most things asyncronously and does all data handling in the
event loop. It actually uses the main loop stuff from glib so it can be
used with non-graphical apps too.

Hope this helps.

/Matt

-- 
Matt Goodall, Software Engineer  |  Isotek Electronics Ltd
mailto:mgg isotek co uk          |  Claro House, Servia Road
http://www.isotek.co.uk          |  Leeds, LS7 1NL
Tel: +44 113 234320              |  England





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]