How to use socket conditions ?
- From: Jacques Pelletier <jpelletier ieee org>
- To: gtk-app-devel-list gnome org
- Subject: How to use socket conditions ?
- Date: Sat, 11 Jul 2015 00:09:54 -0400
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]