GSocket questions

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

 



Hi,

I have an application using (tcp) GSockets objects. The thing I am trying to figure out is how to be notified when the peer closes the socket. My idea so far has been to use g_socket_create_source () and set G_IO_HUP as a condition.

The problem is that it does not always work.

Let's call:
- "server-side" GSocket those associated with a GSocketConnection obtained in the callback of the "incoming" signal of a GSocketService object
- and "client side" GSocket those obtained after g_socket_client_connect_to_host_async()/g_socket_client_connect_to_host_finish() calls.

For "server-side" GSocket I do get the G_IO_HUP condition in the callback of g_socket_create_source(); I don't with "client" GSocket, I do seem to receive a G_IO_IN but when I try to read from it, it does not give an error but returns a 0 byte read.

Now I try to make sense of the API documentation for g_socket_create_source () which says:
"It is meaningless to specify G_IO_ERR or G_IO_HUP in condition; these conditions will always be reported output if they are true."

I don't really understand the statement though it seems to imply that G_IO_HUP will not trigger the callback and will be ignored. If that so how can you be notified when a socket is closed by the peer?

Another function is unclear to me: g_socket_is_connected(). When I call this function:
- if it is a "client side" GSocket then it always return FALSE
- if it is a "server side" GSocket it always return TRUE.

Am I missing something? Could it be the symptom of a problem deep in my code (I cannot really show it here as it is really long)?

Thanks for any help,

Philippe Rouquier
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux