Hi, I have a gtk program which uses GIOChannel to process data from a socket asynchronously. Like this: int main (int argc, char* argv[]) { // int socket is a socket which is set to non-blocking mode GIOChannel* channel = g_io_channel_unix_new(socket); // gio_read_socket() is called when there is somet data in the socket g_io_add_watch(channel, G_IO_IN | G_IO_HUP, gio_read_socket, NULL) gtk_main (); // never gets here } I would like to know if it is possible to change my program to process data form a socket synchronously? int main (int argc, char* argv[]) { // int socket is a socket GIOChannel* channel = g_io_channel_unix_new(socket); for(;;) { //block until there is data from channel.... if (g_io_channel_read_line(channel...) != G_IO_STATUS_ERROR) { // call my gio_read_socket() function to process data from channell gio_read_socket(channel...) } // My question is if i do the above, how can I call gtk_main()? Isn't gtk_main() supposed to create its own message loop for input events, UI events, how can I process those events if i have my own for(;;) loop? // Never get here now? //gtk_main() } Thank you for any suggestion. On Sun, Feb 7, 2010 at 4:56 PM, silverburgh <silverburgh.meryl@xxxxxxxxx> wrote: > Hi, > > I am trying to use GIOChannel with a socket on Linux. > I would like to know if I need to set the socket to 'non blocking' > mode before I setup the GIOChannel? > And If I can mix my GIOChannel read/write operation synchronously and > asynchronously? If yes, how can I do that? > > Thank you. > _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list