问题
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.
回答1:
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;
}
来源:https://stackoverflow.com/questions/5758770/glib-network-connection-example