Changeset 4061:9970635ad32c in roaraudio


Ignore:
Timestamp:
07/15/10 23:16:44 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added --mode, --bind, --port

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarclientpass.c

    r4060 r4061  
    4040        "  --byteorder BO        - Client uses byteorder BO (default: network)\n" 
    4141        "  --listen              - This is a listen mode connection\n" 
     42        "  --mode MODE           - Set mode of operation: none, listen, connect (default: none)\n" 
     43        "  --bind BIND           - Set host/node/path for mode listen and connect\n" 
     44        "  --port PORT           - Set port for mode listen and connect\n" 
     45//        "  --type TYPE           - Set type for mode listen and connect (default: unknown)\n" 
    4246        "  --help                - Show this help\n" 
    4347       ); 
     
    6165 int    proto     = ROAR_PROTO_ROARAUDIO; 
    6266 int    byteorder = ROAR_BYTEORDER_NETWORK; 
     67 int    mode      = ROAR_SOCKET_MODE_NONE; 
     68 int    type      = ROAR_SOCKET_TYPE_UNKNOWN; 
     69 char * host      = NULL; 
     70 int    port      = -1; 
    6371 
    6472 for (i = 1; i < argc; i++) { 
     
    8391  } else if ( !strcmp(k, "--listen") ) { 
    8492   flags |= ROAR_CLIENTPASS_FLAG_LISTEN; 
     93  } else if ( !strcmp(k, "--mode") ) { 
     94   k = argv[++i]; 
     95   if ( !strcasecmp(k, "none") ) { 
     96    mode = ROAR_SOCKET_MODE_NONE; 
     97   } else if ( !strcasecmp(k, "listen") ) { 
     98    mode = ROAR_SOCKET_MODE_LISTEN; 
     99    flags |= ROAR_CLIENTPASS_FLAG_LISTEN; 
     100   } else if ( !strcasecmp(k, "connect") ) { 
     101    mode = ROAR_SOCKET_MODE_CONNECT; 
     102    flags -= ROAR_CLIENTPASS_FLAG_LISTEN; 
     103   } else { 
     104    ROAR_ERR("unknown mode: %s", k); 
     105    return 1; 
     106   } 
     107  } else if ( !strcmp(k, "--bind") ) { 
     108   host = argv[++i]; 
     109  } else if ( !strcmp(k, "--port") ) { 
     110   port = atoi(argv[++i]); 
    85111  } else { 
    86112   ROAR_ERR("unknown argument: %s", k); 
     
    98124 } else { 
    99125  roar_debug_set_stderr_fh(ROAR_STDERR); 
     126 } 
     127 
     128 if ( mode != ROAR_SOCKET_MODE_NONE ) { 
     129  if ( clientfh != -1 ) { 
     130   ROAR_ERR("Too may socket types given"); 
     131   return 30; 
     132  } 
     133 
     134  clientfh = roar_socket_open(mode, type, host, port); 
     135 
     136  if ( clientfh == -1 ) { 
     137   ROAR_ERR("Unabled to open socket"); 
     138   return 31; 
     139  } 
    100140 } 
    101141 
Note: See TracChangeset for help on using the changeset viewer.