Re: poll with timeout 0 in main loop



On Fri, 22 Oct 2010 13:53:55 +0100
Chris Vine <chris cvine freeserve co uk> wrote:

On Fri, 22 Oct 2010 10:37:01 +0000
Juan Pablo L. <jpablolorenzetti hotmail com> wrote:
i attached the code but did not make thru, here is the server code:

Something odd is going on.

I see you are using GIOChannel not to do any reading, but in order to
notify you that a connection is available.  poll()/select() of course
support this in unix-like systems, but I don't know if GIOChannel
does (I have never tried). Possibly it only works if you set the
channel as non-blocking with g_io_channel_set_flags() rather than by
manipulating the file descriptor directly, which you have done.
Again, I don't know.

Actually, in this usage (attaching the file descriptor of a listening
socket to a main loop) there is no need to make the file descriptor
non-blocking since you will not make any blocking calls on it until you
actually get to call accept() to establish the connection, and you may
get undefined behaviour if you do - I don't know what POSIX says about
that when you attempt to use poll() with it.  Once poll() indicates
that a connection is available, accept() can't block anyway.

Does it work if you omit your call to fctl()?

Chris



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