Пример #1
0
int run_main (int argc, ACE_TCHAR *argv[])
{
  // parse options and run in appropriate mode
  int opt             = 0;
  int auto_test_recv  = 0;
  int result          = 0;
  ACE_Get_Opt opts (argc, argv, ACE_TEXT ("p:t:n:sra"));
  while ((opt = opts ()) != -1)
    switch (opt)
      {
      case 'a':
        auto_test_recv = 1;
        break;
      case 's':
        return (run_sender());
      case 'r':
        {
          if (auto_test_recv)
            {
              ACE_START_TEST (ACE_TEXT ("SOCK_Dgram_Bcast_Test_Child"));
              result = run_receiver ();
              ACE_END_TEST;
              return result;
            }
          return (run_receiver ());
        }
      case 'n':
        dgrams_no = ACE_OS::atoi (opts.opt_arg ());
        break;
      case 't':
        dgram_recv_timeout.msec (ACE_OS::atoi (opts.opt_arg ()));
        break;
      case 'p':
        dgram_port = ACE_OS::atoi (opts.opt_arg ());
        break;
      default:
        print_usage ();
        return -1;
      }
  ACE_START_TEST (ACE_TEXT ("SOCK_Dgram_Bcast_Test"));

#ifndef ACE_LACKS_IOCTL
  result = run_auto_test (argc > 0 ? argv[0] : ACE_TEXT ("SOCK_Dgram_Bcast_Test"));
#endif

  ACE_END_TEST;
  return result;
}
Пример #2
0
int main(int argc, char** argv)
{

	//check the correct usage
	if (argc != 3){
		printf("Usage: %s <port> <filename>\n", argv[0]);
		exit(1);
	}

	/*
	 * initialize the mp3channel library, you can modify the parameters of
	 * setMP3Params:
	 * 	1st - maximum queue size
	 * 	2nd - 0 for no congestion / 1 activates random traffic
	 * 	3rd - packet transmission delay
	 * 	4th - probability of packet loss (value between 0 and 1)
	 * 	5th - probability of corrupting one byte of a packet that was not dropped
	 *
	 *	DO NOT use this function anywhere else in your code, or your score will be 0
	 */
	mp3_init();
	setMP3Params(1000, 0, 10000, 0.0, 0.0);

	// Run start the client
	run_receiver(argv[1], argv[2]);

	// Once the client has received the file, print stats on the client side and exit
	printMP3Statistics();

	return 0;
}
Пример #3
0
Файл: bank.c Проект: hnkien/bank
void run_bank(BankConfig config) {
	Node *store = get_new_node('$', ROOT_TRIE_LEVEL);
	pthread_t sender_thread = 0;
	int i = 0;
	int downstream_up[config.destiny_host_count];
	for (i = 0; i < config.destiny_host_count; i++) {
		downstream_up[i] = 1;
	}
	void *arg[3];
	arg[0] = (void*) store;
	arg[1] = (void*) &config;
	arg[3] = (void*) downstream_up;

	pthread_create(&sender_thread, NULL, &run_sender, (void *) arg);
	run_receiver(store, config);
}
Пример #4
0
/* \brief Thread main function to run run_receiver function
   \note run_receiver return valu is stored in receiver_exit_code global variable
*/
static ACE_THR_FUNC_RETURN run_thread_receiver (void *)
{
  receiver_exit_code = run_receiver ();
  return 0;
}
Пример #5
0
int main(int argc, char *argv[])
{
  int i=1,j=1,k=0;
  char c, flag = 0, *host = NULL, *port = NULL;

  struct spead_socket *x = NULL;

  if (argc < 2)
    return usage(argv);

  while (i < argc){
    if (argv[i][0] == '-'){

      c = argv[i][j];

      switch(c){
        case '\0':
          j = 1;
          i++;
          break;
        case '-':
          j++;
          break;

        /*switches*/  
        case 'h':
          return usage(argv);

        case 'r':
          j++;
          flag = 1;
          k = 1;
          break;

        case 's':
          j++;
          flag = 0;
          break;

          /*settings*/
        
        default:
          fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
          return EX_USAGE;
      }

    } else {
      /*parameters*/
      switch (k){
        case 0:
          host = argv[i];
          k++;
          break;
        case 1:
          port = argv[i];
          k++;
          break;
        default:
          fprintf(stderr, "%s: extra argument %s\n", argv[0], argv[i]);
          return EX_USAGE;
      }
      i++;
      j=1;
    }
  }

  if (k < 2){
    fprintf(stderr, "%s: insufficient arguments\n", __func__);
    return EX_USAGE;
  }

  if (register_signals_us() < 0)
    return EX_SOFTWARE;

  x = create_udp_spead_socket(host, port);
  if (x == NULL){
    return EX_SOFTWARE;
  }

  switch (flag){
    
    case 0: /*sender*/
#ifdef DEBUG
      fprintf(stderr, "%s: running sender\n", __func__);
#endif

#if 0
      if (connect_spead_socket(x) < 0){
        goto cleanup;
      }
#endif 

#if 1
      if (run_sender(x) < 0){
#ifdef DEBUG
        fprintf(stderr, "%s: run sender fail\n", __func__);
#endif
      }
#endif

      break;

    case 1: /*receiver*/
#ifdef DEBUG
      fprintf(stderr, "%s: running receiver\n", __func__);
#endif

#if 0
      if (bind_spead_socket(x) < 0){
        goto cleanup;
      }
#endif

#if 1
      if (run_receiver(x) < 0){
#ifdef DEBUG
        fprintf(stderr, "%s: run receiver fail\n", __func__);
#endif
      }
#endif

      break;
  }

cleanup:  
  destroy_spead_socket(x);
  
  destroy_shared_mem();
#ifdef DEBUG
  fprintf(stderr,"%s: done\n", __func__);
#endif
  return 0;
}