#include "../network/infrastructure_client.h"
#include <unistd.h>

const int N_MSG = 10;

main(int argc, char **argv)
{	
	int i;
	char msg[5];

	//if (argc != 2) {
    //  printf("usage: testSB <IPaddress>");
    //  exit(1);
    //}
    
    network_interface *c = new infrastructure_client();
    int r = c->join();
    printf("(join) number of neighbors: %d\n", c->neighbors().size());
    while (r != 0) {
      sleep(10);
      r = c->join();
      printf("(join) number of neighbors: %d\n", c->neighbors().size());
    }
    //send multiple datagrams as they may get lost
    for (i = 0; i < N_MSG ; i++) {
      msg[0] = 'a' + i;
      msg[1] = '\0';
      printf("broadcast\n");
        r = c->broadcast(1, msg, 2);
        if (r < 0)
          return 0;
    }	
   
}
  
