Not sure how glib socket handles this, but typically for socket disconnects 
you'll get an indication that there is content ready to read on the socket 
(say, from a select call) but when you read from the socket, it reports zero 
bytes and no errors. That's the indication that the other side hung up. 

--carl

> On Jul 11, 2015, at 12:09 AM, Jacques Pelletier <jpellet...@ieee.org> wrote:
> 
> Hi,
> 
> I'm using a glib socket: when a client (glib) is connected to a server, the 
> client doesn't get the HUP messages when the server closes its connection.
> 
> Here is my code below:
> 
> gboolean SocketPollRead(gpointer data)
> {
>  switch (g_socket_condition_check(ptSocket,G_IO_IN | G_IO_ERR | G_IO_HUP)) // 
> doc says G_IO_HUP isn't needed here
>    {
>        case G_IO_IN:
>            /* Works fine, no problems */
>            ptSocketInNbBytes = 
> g_socket_receive(ptSocket,ptSocketInBuffer,1024,NULL,NULL);
>            GuiTerminalPutInput((unsigned char *) 
> ptSocketInBuffer,ptSocketInNbBytes);
>            break;
>        case G_IO_ERR:
>            /* I don't get any printed messages when server disconnects */
>            fprintf(stderr,"Socket ERR\n");
>            SocketClose();
>            break;
>        case G_IO_HUP:
>            /* I don't get any printed messages when server disconnects */
>            fprintf(stderr,"Socket HUP\n");
>            SocketClose();
>            break;
>        default:
>        ;
>    }
> 
>  return Poll_Socket;
> }
> 
> How do I make this work?
> 
> Thanks!
> 
> JP
> 
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to