[gnet] non-blocking UDP sockets



Hello,

I use GTcpSocket in a non-blocking way by calling
gnet_tcp_socket_get_io_channel() to get the GIOChannel and then using
g_io_channel_set_flags() to flip the G_IO_FLAG_NONBLOCK bit.  Then,
whenever I want to read or write to the socket I use
g_io_channel_read/write_chars() directly.  This is working out fine.

I am wondering how I would be able to do the same thing with UDP
sockets.  The GUdpSocket documentations says the following:
"gnet_udp_socket_send() will block if the OS cannot buffer the packet
immediately. gnet_udp_socket_receive() will block until there is a
packet available to receive."  But, it also says the following: "Note
that a UDP socket's GIOChannel is not a normal GIOChannel -- it should
not be written to or read from directly."

If I get the GIOChannel using gnet_udp_socket_get_io_channel() and set
the G_IO_FLAG_NONBLOCK bit will gnet_udp_socket_send/recieve() still
block?  If so, is there some other way to make a GUdpSocket be
non-blocking?

Thanks in advance,
Mark Drago.

Attachment: signature.asc
Description: This is a digitally signed message part



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