RE: Help with GIOChanel on Win32 - How do I know that a socket was closed?



Hello.

Hi, :)


I'm trying to use GIOChannels, but I probably didn't understand the
proper way to use them (or is it a bug?).

Using:
    g_io_add_watch(io,
         G_IO_IN | G_IO_PRI | G_IO_NVAL | G_IO_ERR | G_IO_HUP,
         foo,
         NULL);

should call my callback (foo) when the connection finishes, right? But
it never gets called when the connection ends.
My code is bellow.


g_io_add_watch () only allows you to know when when something changes on
the file descriptor associated with the channel (from my experience).

I think the reason for not being notified when you have been
disconnected, is because GIOChannels are used for handling file
descriptors and file (for example) never has a disconnected state.

In the past, when I have wanted to know if I have been disconnected I
have looked out for:
        - G_IO_NVAL | G_IO_ERR
        - G_IO_HUP
        - G_IO_STATUS_ERROR returned from g_io_channel_read_chars ()
        - 0 bytes returned from g_io_channel_read_chars ()


Regards,
Martyn



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