Ejemplo n.º 1
0
bool Client::initLocal( const int argc, char** argv )
{
    if( _impl->name.empty() && argc > 0 && argv )
    {
        const boost::filesystem::path prog = argv[0];
        setName( prog.stem().string( ));
    }

    const auto options = _getProgramOptions();
    arg::variables_map vm;
    try
    {
        Strings args;
        for( int i = 0; i < argc; ++i )
            if( strcmp( argv[i], "--" ) != 0 )
                args.push_back( argv[i] );

        arg::store( arg::command_line_parser( args )
                        .options( options ).allow_unregistered().run(), vm );
        arg::notify( vm );
    }
    catch( const std::exception& e )
    {
        LBERROR << "Error in argument parsing: " << e.what() << std::endl;
        return false;
    }

    const bool isClient = vm.count( "eq-client" );
    std::string clientOpts;

    if( vm.count( "eq-layout" ))
        _impl->activeLayouts.push_back( vm["eq-layout"].as< std::string >( ));
    if( vm.count( "eq-gpufilter" ))
        _impl->gpuFilter = vm["eq-gpufilter"].as< std::string >();
    if( vm.count( "eq-modelunit" ))
        _impl->modelUnit = vm["eq-modelunit"].as< float >();

    LBVERB << "Launching " << getNodeID() << std::endl;
    if( !Super::initLocal( argc, argv ))
        return false;

    if( isClient )
    {
        LBVERB << "Client node started from command line with option "
               << clientOpts << std::endl;

        if( !_setupClient( clientOpts ))
        {
            exitLocal();
            return false;
        }

        _impl->running = true;
        clientLoop();
        exitClient();
    }

    _impl->initQt( argc, argv );
    return true;
}
Ejemplo n.º 2
0
int main()
{
	table = new Table();
	projector = new Projector();
	// create thread with arbitrary argument for the run function
    _beginthread(serverLoop, 0, (void*)12);

	clientLoop();
	return 0;
}
Ejemplo n.º 3
0
/**
 * Listens to clients
 * @param server
 */
void createClient(int server, char * document_root) {


    int socket_client;


    // BOUCLE POUR ECOUTER TOUUUUT LES CLIENTS
    while (1) {
        //printf("Waiting for client %d\n", CLIENT_ID);
        socket_client = accept(server, NULL, NULL);
        CLIENT_ID++;

        beforeUpdateStats();
        get_stats()->served_connections++;
        statsUpdated();

        if (socket_client == -1) {
            perror("accept");
            /*  traitement d’erreur  */
            printf("Server error...");
        }


        pid_t pid = fork();

        // Call client
        if (pid == 0) {
            clientLoop(socket_client, document_root);
        } else {
            close(socket_client);
        }



    }

}