4

Can you advice some network connection example made with glib/gio libraries. There is quite a good reference manual, but no full example even for basic things.

It will be used for simple sending and receiving files as a part of program.

qnikst
  • 302
  • 1
  • 9
  • I've found unanswered question on SO http://stackoverflow.com/questions/2417681/need-help-implementing-simple-socket-server-using-gioservice-glib-glib-gio and try to use it as an example, but still want to find finished example. – qnikst Apr 22 '11 at 18:56

1 Answers1

3

How about like this? There is similar question at Fetch a file from web: in GTK using C

#include <gio/gio.h>

int main()
{
        const gchar *uri = "https://stackoverflow.com/questions/5758770/";
        GFile *in;
        GFile *out;
        GError *error = NULL;
        gboolean ret;

        g_type_init();

        in = g_file_new_for_uri(uri);
        out = g_file_new_for_path("/tmp/a");

        ret = g_file_copy(in, out, G_FILE_COPY_OVERWRITE,
                          NULL, NULL, NULL, &error);
        if (!ret)
                g_message("%s", error->message);

        return 0;
}
Community
  • 1
  • 1
Yasushi Shoji
  • 4,028
  • 1
  • 26
  • 47