Re: Data available for reading in a GIOChannel

2007-05-30 Thread Chris Vine
On Tue, 2007-05-29 at 22:42 +0100, Robert Pearce wrote: > My understanding was that the Glib idle task checks the IO channel > status and calls the callback if it's ready. Since Glib is non-threaded, > this cannot happen during a previous execution of the callback. And > since it uses the chann

Re: Data available for reading in a GIOChannel

2007-05-30 Thread Tristan Van Berkom
On Tue, 2007-05-29 at 22:42 +0100, Robert Pearce wrote: > On Tue, 29 May 2007, Jonathan Winterflood > <[EMAIL PROTECTED]> wrote : > > > >A question arises, though: is it possible that the channel will recieve > >the last of the data between the > >time g_io_channel_read_chars returns G_IO_STAT

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Ana
Looking at the glib source here: glib/giochannel.c glib/giochannel.h glib/giounix.c You can see that, at least on a *nix machine, g_io_channel_read_chars() calls the c library read() on a file descriptor in the GIOChannel struct. The segment:

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Robert Pearce
On Tue, 29 May 2007, Jonathan Winterflood <[EMAIL PROTECTED]> wrote : > >A question arises, though: is it possible that the channel will recieve >the last of the data between the >time  g_io_channel_read_chars  returns G_IO_STATUS_AGAIN and the callbac >k exits, and that the callback will not be

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Jonathan Winterflood
Thanks for your precisions on where this difference comes from :) I guess g_io_channel_set_flags(_channel, G_IO_FLAG_NONBLOCK, NULL); is good for switching to non-blocking mode. A question arises, though: is it possible that the channel will recieve the last of the data between the time g_io

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Travis Miller
Callbacks on a GIOChannel (as described) are re-entrant!. I know since i have hit this problem. Essentially you must read what you can. If its a socket you would have soimething like bytes_read = recv( fd, ( void * ) ( &buffer[ current_byte ] ), expected_size );

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Paul Davis
On Mon, 2007-05-28 at 17:26 +0200, Jonathan Winterflood wrote: > Hi, > > > you never know how much readable data is available until you read > it, you are only ever guaranteed to have one byte of data available > for reading anyway. > > In my opinion, the channel should _always_ know how much dat

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Jonathan Winterflood
Hi, you never know how much readable data is available until you read it, you are only ever guaranteed to have one byte of data available for reading anyway. In my opinion, the channel should _always_ know how much data is available, how can it tell that there is nothing there?... Plus, it can

Re: Data available for reading in a GIOChannel

2007-05-29 Thread Alexandre Moreira
On 5/28/07, Ana <[EMAIL PROTECTED]> wrote: > On Mon, May 28, 2007 at 04:42:11PM -0300, Alexandre Moreira wrote: > > On 5/28/07, Robert Pearce <[EMAIL PROTECTED]> wrote: > > > On Sun, 27 May 2007 16:57:03 +0200 Jonathan wrote: > > > > Hi, > > > > > > > > I need to read a large amount of data from a

Re: Data available for reading in a GIOChannel

2007-05-28 Thread Ana
On Mon, May 28, 2007 at 04:42:11PM -0300, Alexandre Moreira wrote: > On 5/28/07, Robert Pearce <[EMAIL PROTECTED]> wrote: > > On Sun, 27 May 2007 16:57:03 +0200 Jonathan wrote: > > > Hi, > > > > > > I need to read a large amount of data from a GIOChannel (200K, over > > > the internet). > > > > > >

Re: Data available for reading in a GIOChannel

2007-05-28 Thread Alexandre Moreira
On 5/28/07, Robert Pearce <[EMAIL PROTECTED]> wrote: > On Sun, 27 May 2007 16:57:03 +0200 Jonathan 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 GIOCha

Re: Data available for reading in a GIOChannel

2007-05-28 Thread Robert Pearce
On Sun, 27 May 2007 16:57:03 +0200 Jonathan 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 > G

Re: Data available for reading in a GIOChannel

2007-05-28 Thread Armin Burgmeier
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tristan Van Berkom wrote: > 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,

Re: Data available for reading in a GIOChannel

2007-05-28 Thread Tristan Van Berkom
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

Data available for reading in a GIOChannel

2007-05-28 Thread Jonathan Winterflood
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, &(_imageDat