We use `g_socket_new` to open a socket and create a `GIOChannel` objct. ```c #include #include #include #include #include #include #define BLOCK_SIZE 1024 #define GG g_print("line %d\n",__LINE__) static gboolean gio_read_socket (GIOChannel *channel, GIOCondition condition, gpointer data) { static int r = 0; r++; printf("r=%d\n",r); char buf[1024]; gsize bytes_read; GError *error = NULL; g_print("gio_read_socket\n"); if (condition & G_IO_HUP) return FALSE; /* this channel is done */ GG; g_print("channel not done\n"); // g_io_channel_read (channel, buf, sizeof (buf), &bytes_read); g_io_channel_read_chars (channel, buf, sizeof (buf), &bytes_read, &error); g_print("g_io_channel_read_chars\n"); g_print("%ld bytes read\n",bytes_read); g_assert (error == NULL); GG; buf[bytes_read] = '\0'; g_print ("%s", buf); int i=0,l=32; for(int i=0; i