2011-04-22 6 views
3

glib/gio 라이브러리로 만든 네트워크 연결 예를 조언 해 줄 수 있습니까? reference manual은 꽤 괜찮은 편이지만 기본적인 경우에도 완전한 예는 없습니다.glib 네트워크 연결 예

프로그램의 일부로 파일을 보내고받는 데 사용됩니다.

+0

에서 비슷한 질문이 있습니다 내가 SO 에 답이없는 질문을 발견했습니다 http://stackoverflow.com/questions/2417681/need-help-implementing-simple-socket-server-using-gioservice- glib-glib-gio를 예제로 사용하려고 시도하지만 여전히 완성 된 예제를 찾고 싶습니다. – qnikst

답변

2

어때? 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; 
}