Re: Data available for reading in a GIOChannel
- From: Tristan Van Berkom <tvb gnome org>
- To: Jonathan Winterflood <jonathan winterflood gmail com>
- Cc: gtk-list gnome org
- Subject: Re: Data available for reading in a GIOChannel
- Date: Mon, 28 May 2007 09:34:08 -0400
On Sun, 2007-05-27 at 16:57 +0200, Jonathan Winterflood wrote:
> Hi,
>
> I need to read a large amount of data from a GIOChannel (200K, over the internet).
>
> So far, I use the gnet library to create the
> socket, and then I use the GIOChannel to integrate the read/writing into the program's loop (a GTK application)
>
> I use g_io_add_watch(_channel, G_IO_IN, &(_imageDataReadyForReading),
> this); to register the callback for data reading.
>
> How can I determine the number of bytes available for reading, so as
> not to block on reading the data?
I dont know if gnet provides anything for this, what I typically
do is:
while (select (fds, readable condition)) {
read (a single byte of data);
}
Regardless of the method used, you never know how much readable
data is available until you read it, you are only ever gaurunteed
to have one byte of data available for reading anyway.
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]