Re: [gnet] G_IO_Condition on a iochannel for a socket



What you describe is the correct behavior. When a client disconnects you
get a G_IO_IN and a read of 0. The G_IO_IN is used to signal that your
received something, and the read of 0 is the standard way sockets say the
other end closed the connection. Take a look at the gnet's  echoserver &
echoclient --async examples.

Andy

On Wed, 27 Jun 2001, Aschwin van der Woude wrote:

> Hi,
>
> It is not clear to me if this question belongs on this list or on the
> glib-list, so please forgive and correct me if this questions belongs to
> the glib-list.
>
> We are not members of this mailinglist, so please cc: the reply to us.
>
> I am participating in a small game-project. For this project we build a
> client/server, decided to use gnet and glib, and use TCP/IP as a network
> protocol.
>
> Everything works fine, accepting connections, receiving data and so forth.
> We use g_io_add_watch() to received socket/iochannel conditions.
>
> But we noticed when the client-side hangs up the connection (tested with
> telnet), a condition G_IO_IN is issued on the server.
> There is no data to be received from the stream, so currently we used
> this condition and this last fact to assume the otherside of the
> connection has hung up. This solution seems to work fine for our
> test-cases, but I doubt it is the correct solution.
>
> We initially expected a G_IO_HUP condition to be received when the
> otherside of the connection is closed.
>
> We currently use the following versions :
>
> glib version:    1.2.10-ximian.2
> gnet version:    1.0.4-ximian.2
>
> Could you shed some light on this curiosity?
>
>
> Thanks,
>
> Aschwin
>
> --
>
>    If I have been able to see further,
>    it was only because I stood on the shoulders of giants.
>
>                                     Sir Isaac Newton
>
>
>
> _______________________________________________
> gnet mailing list
> gnet gnetlibrary org
> http://www.gnetlibrary.org/mailman/listinfo/gnet
>




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