int main( int argc, char ** argv )
{
    uint8_t i = 0;
    uint16_t port = 0;
    uint8_t threadcount = 0;

    struct acceptor * a = NULL;
    struct iothread ** thrgroup = NULL;

    if ( argc != 3 )
    {
        printf("echoserver [port] [threadcount] .\n");
        return 0;
    }

    signal( SIGPIPE, SIG_IGN );
    signal( SIGINT, echoserver_signal_handler );
    signal( SIGTERM, echoserver_signal_handler );

    port = (uint16_t)atoi( argv[1] );
    threadcount = (uint8_t)atoi( argv[2] );

    a = acceptor_create( "127.0.0.1", port );

    thrgroup = (struct iothread **)malloc( threadcount*sizeof(struct iothread *) );
    for ( i = 0; i < threadcount; ++i )
    {
        thrgroup[i] = iothread_create( i+1, a );
    }

    isstarted = 1;
    while ( isstarted )
    {
    #if defined(__FreeBSD__)
        sleep(2);
    #else
        pause();
    #endif
    }

    for ( i = 0; i < threadcount; ++i )
    {
        evsets_destroy( thrgroup[i]->core_sets );
    }

    return 0;
}
Example #2
0
File: libnet.c Project: luozy/evnet
void* evnet_createacceptor(unsigned short port, pfn_msg_handler handler, void *pUsr)
{
    return acceptor_create(port, handler, pUsr);
}