Exemplo n.º 1
0
int main( int argc, char* argv[] )
{
	Gate gate;
 	bool debug = false;

	char c;
  	while ((c = getopt (argc, argv, "tup:a:d")) != -1)
	    switch (c)
	    {
	      case 'd':
	      	debug = true;
	      	break;
	      case 'p':
	        int port;
	        sscanf( optarg, "%d", &port );
	        gate.setPort(port);
	        break;
	      case 'a':
	        gate.setAddr(optarg);
	        break;
	      case 't':
	        gate.setTCP();
	        break;
	      case 'u':
	        gate.setUDP();
	        break;
	      case '?':
	        if ( optopt == 'p' || optopt == 'a')
	          fprintf (stderr, "Option -%c requires an argument.\n", optopt);
	        else if (isprint (optopt))
	          fprintf (stderr, "Unknown option `-%c'.\n", optopt);
	        else
	          fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
	        return 1;
	      default:
	        abort ();
	    }

    gate.bind( handle );

    return 0;
}