예제 #1
0
파일: helloworld.c 프로젝트: dyu/librinoo
void task_server(void *sched)
{
	t_socket *server;
	t_socket *client;

	server = rinoo_tcp_server(sched, IP_ANY, 4242);
	while ((client = rinoo_tcp_accept(server, NULL, NULL)) != NULL) {
		rinoo_task_start(sched, task_client, client);
	}
	rinoo_socket_destroy(server);
}
예제 #2
0
void server_func(void *unused(arg))
{
	t_socket *server;
	t_socket *client;

	server = rinoo_tcp_server(rinoo_sched_self(), IP_ANY, 4242);
	XTEST(server != NULL);
	client = rinoo_tcp_accept(server, NULL, NULL);
	XTEST(client != NULL);
	rinoo_log("client accepted");
	rinoo_task_start(rinoo_sched_self(), process_client, client);
	rinoo_socket_destroy(server);
}
예제 #3
0
파일: http.c 프로젝트: dyu/librinoo
void http_server(void *sched)
{
	t_ip ip;
	uint16_t port;
	t_socket *server;
	t_socket *client;

	server = rinoo_tcp_server(sched, IP_ANY, 4242);
	XTEST(server != NULL);
	client = rinoo_tcp_accept(server, &ip, &port);
	XTEST(client != NULL);
	rinoo_log("server - accepting client (%s:%d)", inet_ntoa(*(struct in_addr *) &ip), port);
	rinoo_task_start(sched, http_server_process, client);
	rinoo_socket_destroy(server);
}
예제 #4
0
/**
 * HTTP server processing callback
 *
 * @param context Pointer to a HTTP easy context
 */
static void rinoohttp_easy_server_process(void *context)
{
	t_rinoosocket *client;
	t_rinoohttp_easy_context *c_context;
	t_rinoohttp_easy_context *s_context = context;

	while ((client = rinoo_tcp_accept(s_context->socket, NULL, NULL)) != NULL) {
		c_context = malloc(sizeof(*c_context));
		if (c_context == NULL) {
			rinoo_socket_destroy(client);
			rinoo_socket_destroy(s_context->socket);
			free(s_context);
			return;
		}
		c_context->socket = client;
		c_context->routes = s_context->routes;
		c_context->nbroutes = s_context->nbroutes;
		rinoo_task_start(s_context->socket->node.sched, rinoohttp_easy_client_process, c_context);
	}
	rinoo_socket_destroy(s_context->socket);
	free(s_context);
}