Search code examples
clinuxglibgtk2gobject

gtk networking tutorials / resources / examples


Does anyone now where i can find some good tutorials / code samples regarding networking in gtk / glib. I'm trying to write a client application that connects to a simple server that echos back what it receives, using Gtk2 and i'm not sure how to go about it. I want to do async read / writes without using threads but i'm not sure what is the best approach. The API reference isn't much help - GIOChannel, GIOStream, GSocketClient, etc - which one to use?

The fallback would be to use blocking IO in another thread.

I'm not interested in portability.

"Rant: How do the GTk / GLib developers expect people to use their framework without good documentation? Why do i even bother when i could do it using QT. I wan't to learn more C, thats why i bother!"


Solution

  • I use the functions g_socket_client_new(), g_socket_client_connect_async(), g_socket_client_connect_finish().

    And then the g_io_stream_get_input_stream() and g_io_stream_get_output_stream() to get the streams and do the real send and receives.

    If you really need it, I may have some example code around...