Exemplo n.º 1
0
receiver session::open_receiver(const std::string &addr, const link_options &lo)
{
    receiver rcv = create_receiver();
    rcv.source().address(addr);
    rcv.open(lo);
    return rcv;
}
Exemplo n.º 2
0
int main( int argc, char **argv ) {
    int index = if_nametoindex( "switch0" );
    struct ring *ring = create_receiver( index );

    if ( debug(argc, argv) ) {
        exit( 0 );
    }

    receive_loop( ring );
    return 0;
}
Exemplo n.º 3
0
/**
 * Builds the Chariot test.
 *  
 * @param i_testHandle   Test object to be configured.
 */
static void
build_test(
    CHR_TEST_HANDLE i_testHandle)
{
    CHR_CHANNEL_HANDLE channel1;
    CHR_CHANNEL_HANDLE channel2;
    CHR_CHANNEL_HANDLE channel3;
    CHR_RECEIVER_HANDLE receiver1;
    CHR_RUNOPTS_HANDLE runOptionsHandle;
    CHR_API_RC rc;

    rc = CHR_test_set_filename(
            i_testHandle,
            lc_testFile,
            strlen(lc_testFile));
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "test_set_filename");

    /*
     * Create channel objects.
     */
    channel1 = create_channel(&lc_channelSpec1);
    channel2 = create_channel(&lc_channelSpec2);
    channel3 = create_channel(&lc_channelSpec3);

    /*
     * Add channels to test.
     */
    rc = CHR_test_add_channel(i_testHandle, channel1);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "test_add_channel");

    rc = CHR_test_add_channel(i_testHandle, channel2);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "test_add_channel");

    rc = CHR_test_add_channel(i_testHandle, channel3);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "test_add_channel");

    /*
     * Create receiver objects.
     */
    receiver1 = create_receiver(&lc_receiverSpec1);

    /*
     * Create IPTV pairs.
     */
    create_pair(receiver1, channel1);
    create_pair(receiver1, channel2);
    create_pair(receiver1, channel3);

    /*
     * Add receivers to test.
     */
    rc = CHR_test_add_receiver(i_testHandle, receiver1);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "test_add_receiver");

    /*
     * Set a time limit on the test.
     */
    rc = CHR_test_get_runopts(i_testHandle, &runOptionsHandle);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "test_get_runopts");

    rc = CHR_runopts_set_test_duration(
            runOptionsHandle,
            TEST_DURATION);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "runopts_set_test_duration");

    rc = CHR_runopts_set_test_end(
            runOptionsHandle,
            CHR_TEST_END_AFTER_FIXED_DURATION);
    if (rc != CHR_OK)
        show_error(i_testHandle, rc, "runopts_set_test_end");

} /* build_test */
Exemplo n.º 4
0
int main(int argc, char **argv)
{
    int ret = -1, tries = RETRY_COUNT;
    char option;

    /* we want unbuffered output */
    setbuf(stdout, NULL);

    while((option = getopt(argc, argv, option_string)) != -1) {
        switch(option) {
        case 'h':
            strncpy(server_host_name, optarg, MAX_HOST_NAME_LEN);
            break;
        case 't':
            server_tcp_port = atoi(optarg);
            break;
        case 'u':
            server_udp_port = atoi(optarg);
            break;
        case 'n':
            strncpy(member_name, optarg, MAX_MEMBER_NAME_LEN);
            break;
        default:
            printf("invalid option %c\n",option);
            usage(argv);
            break;
        }
    }

#ifdef USE_LOCN_SERVER

    printf("Using location server to retrieve chatserver information\n");

    if (strlen(member_name) == 0) {
        usage(argv);
    }

#else

    if(server_tcp_port == 0 || server_udp_port == 0 ||
    strlen(server_host_name) == 0 || strlen(member_name) == 0) {
        usage(argv);
    }

#endif /* USE_LOCN_SERVER */

    /********************************************
     * Spawn receiver process - see create_receiver() in this file.
     */
    debug_sub_print(DBG_RCV, "%s: init receiver process...\n", __func__);

    if ((create_receiver() == -1)) {
        fprintf(stderr, "Could not create receiver process\n");
        exit(1);
    }

    /********************************************
     * Initialize client and start accepting input. 
     */
    server_room_name[0] = '\0'; 
    while (ret != 0) {
       
        tries = RETRY_COUNT; 
        while ((ret = init_client()) != 0) {
            if (tries-- <= 0) {
                /* If we fail to connect RETRY_COUNT times,
                 * just give up.
                 */
                fprintf(stderr, "Problem initiating connection with "
                    "server.\n");
                shutdown_clean(ret);
            }
        }

        if ((ret = main_loop()) != 0) {
            fprintf(stderr, "Trying to reconnect...\n");
        }
    }

    shutdown_clean(ret);
    return 0;
}