Re: g_io_channel_get_buffer_condition



On Mon, 06 Dec 2004 09:03:56 -0500
Owen Taylor <otaylor redhat com> wrote:

On Mon, 2004-12-06 at 14:59 +0100, Hubert Sokolowski wrote:
On Mon, 2004-12-06 at 09:12 +0100, Hubert Sokolowski wrote:
Hi!

I use this function to check if I can write to GIOChannel this
way
if (!(g_io_channel_get_buffer_condition (io_write) & G_IO_OUT))
  {
    printf ("data cannot be written\n");
    return TRUE;
  }

but the above condition is always true. io_write can be a file or
a
pipe.
I can disable this code for a file and then it works fine, but I
need
this
for a pipe.
Do I have to use select instead of this function to check if I
can write
to a file?

What do you mean "can write to a file" ?
sorry, this was about a pipe. but the problem is solved by setting
G_IO_FLAG_NONBLOCK flag on a channel, now g_io_channel_write_chars
returns
with G_IO_STATUS_AGAIN when the channel is full and cannot be
written.

anyway, g_io_channel_get_buffer_condition always returns 0, so I
don't use
it anymore.

Well, no, it's not always returning G_IO_OUT. What would happen is
that
you'd have say 100 bytes left in the buffer. You'd write 200. 100
bytes
would go into the buffer, it would block writing the contents of
the buffer and then write the remaining 100.
it never returns G_IO_OUT, it always returns 0. G_IO_OUT is equal to 4,
G_IO_IN is equal to 1.


-- 
Hubert Sokołowski



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