You are faced with the problem that you have several event systems at a time, but only one thread. Gtk + comes with its own event handler, which ultimately boils down to select() , which wakes up on any user input or other gtk event. You yourself want to work with the network using your own event processing, which usually consists of select() on your socket or using sockets in blocking mode.
One solution is to integrate your events into the Gtk + event loop.
You can make Gtk + watch / select() your sockets and call a certain function when their state changes (reading data). See the โCreating New Source Typesโ section at http://developer.gnome.org/glib/2.30/glib-The-Main-Event-Loop.html
Another solution would be to use the functionality of Gtk +.
As a rule, you donโt want to do something special with sockets that are not easy to port using Glib IO Channels. See http://developer.gnome.org/glib/2.30/glib-IO-Channels.html
The third solution is to start a second thread that processes your network, for example. with posix threads or gtk + threading functionality.
Separating the GUI from the working part of your application is, in general, a good idea. However, for the chat application, it probably does not provide any benefit compared to other solutions. See http://developer.gnome.org/glib/2.30/glib-Threads.html
ypnos source share