【发布时间】:2015-06-29 06:16:20
【问题描述】:
我想在 Libsoup 服务器中实现多线程,这样每次客户端请求到来时,都会创建一个新线程来服务该请求。 如何使用 Libsoup 和 GLib 库来实现这一点?
我目前的服务器主代码是这样的:
sending_file = fopen("abc/project_foo.zip", "r");
fseek(sending_file, 0L, SEEK_END);
size_of_file = ftell(sending_file);
fseek(sending_file, 0L, SEEK_SET);
int port = 15000;
server = soup_server_new(SOUP_SERVER_RAW_PATHS,TRUE,SOUP_SERVER_PORT,port, SOUP_SERVER_SERVER_HEADER,"simple-httpd",NULL);
soup_server_add_handler(server , "/foo" , server_callback, NULL , NULL);
soup_server_run_async (server);
printf("Waiting for Requests...\n");
//Running a main loop so Async will work
GMainLoop *loop;
loop = g_main_loop_new (NULL, TRUE);
g_main_loop_run (loop);
return 0;
【问题讨论】:
-
请分享您迄今为止尝试过的任何方法。
-
我已经添加了我的主要功能代码
标签: c multithreading glib gnome