glib网络连接示例 [英] glib network connection example
本文介绍了glib网络连接示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您能建议一些使用glib/gio库制作的网络连接示例吗? 有相当不错的参考手册,但即使是基本的示例也没有完整的示例.
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.
推荐答案
这样怎么样? 在从Web上获取文件:在GTK中使用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;
}
这篇关于glib网络连接示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文