Here's an additional tip: the third parameter to g_io_add_watch_full is a condition. You want G_IO_IN, that is, a normal incoming message. However, it is a good idea to set up a second watch on the same socket with G_IO_HUP, then set the priority of this watch (second parameter) HIGHER** than the IN watch. HUP will respond if the other end of the socket disconnects -- this is an error situation*. Otherwise, if the connection goes bad, you will get an undesirable event on the IN watch (this will be true for a normal socket setup too, except AFAICT the normal socket API does not allow you to detect HUP, so you are stuck with the "undesirable event", which is a non-stop flood of recv's with no content).
* probably the end of the program unless you set up a means of reconnecting.
** lower number = higher priority