Beispiel #1
0
ERROR_CODE run_service_s(char *program_name, struct hash_map_t *arguments) {
    /* allocates space for the error value that will be used
    to check for an error in the call */
    ERROR_CODE return_value;

    /* initializes the service creating the structures and starting
    the values for the configuration of it */
    return_value = init_service(program_name, arguments);
    if(IS_ERROR_CODE(return_value)) {
        RAISE_AGAIN(return_value);
    }

    /* run the service, blocking the call until the service is
    finished, the retrives the return value from it */
    return_value = run_service();
    if(IS_ERROR_CODE(return_value)) {
        RAISE_AGAIN(return_value);
    }

    /* destroys the service eliminating any structures that have
    been created in the service life-time */
    return_value = destroy_service();
    if(IS_ERROR_CODE(return_value)) {
        RAISE_AGAIN(return_value);
    }

    /* raises no error as the execution of the service went normally
    and no problems have been issued */
    RAISE_NO_ERROR;
}
Beispiel #2
0
void asynnet_delete(asynnet_t asynet)
{
    asynnet_stop(asynet);
	int32_t i = 0;
    for( ;i < asynet->poller_count; ++i){
        destroy_thread(&asynet->netpollers[i].poller_thd);
        destroy_service(&asynet->netpollers[i].netpoller);
	}
    free(asynet);
}
Beispiel #3
0
int main(int argc,char **argv)
{
	setup_signal_handler();
    InitNetSystem();
    struct netservice *tcpclient = new_service();
    tcpclient->connect(tcpclient,"127.0.0.1",8010,(void*)tcpclient,on_connect,10000);
	while(!stop){
        tcpclient->loop(tcpclient,50);
	}
	destroy_service(&tcpclient);
    CleanNetSystem();
    return 0;
}
void destroy_objects_service()
{
    unsigned int i;
    for (i = 0; i < num_objects.services; i++) {
        service *this_service = service_ary[i];
        destroy_service(this_service);
    }
    service_list = NULL;
    if (service_hash_table)
        g_hash_table_destroy(service_hash_table);

    service_hash_table = NULL;
    nm_free(service_ary);
    num_objects.services = 0;
}
Beispiel #5
0
int main(int argc,char **argv)
{
    mutil_thread = 0;
	setup_signal_handler();
	init_clients();
    InitNetSystem();
    struct netservice *tcpserver = new_service();
	tcpserver->listen(tcpserver,argv[1],atoi(argv[2]),(void*)tcpserver,accept_client);
	uint32_t tick,now;
    tick = now = GetSystemMs();
	while(!stop){
		tcpserver->loop(tcpserver,50);
        now = GetSystemMs();
		if(now - tick > 1000)
		{
			printf("client_count:%d,send_count:%d\n",client_count,(packet_send_count*1000)/(now-tick));
			tick = now;
			packet_send_count = 0;
		}
	}
	destroy_service(&tcpserver);
    CleanNetSystem();
    return 0;
}