Re: polling sockets using glib



Peter Robinson <pjr itee uq edu au> writes:

I am writing a server application (using glib) in which I want to be 
able to (frequently) turn polling on and off for given sockets.

You may want to take a look at this:

http://www.daimi.au.dk/~sandmann/watch.h
http://www.daimi.au.dk/~sandmann/watch.c

It allows you to watch arbitrary pollable file descriptors by just
setting a callback. To turn off polling, you just set the callback to
NULL. Ie.,

To watch a descriptor:

        fd_add_watch (fd, data);

To turn polling on:

        fd_set_read_callback (fd, callback);

to turn polling off:

        fd_set_read_callback (fd, NULL);

I have found it to be a more convenient API than the g_io_ stuff in
glib.


Soren



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