int port = 15000;
while(argc > 1 && argv[1][0] == '-'){
const char* arg = argv[1];
- if (strncmp(arg, "-p", 2) == 0 || strncmp(arg, "--port=", 7)){
+ if (strncmp(arg, "-p", 2) == 0 || strncmp(arg, "--port=", 7) == 0){
port = atol(arg + (arg[1] == '-' ? 2 : 7));
if (port <= 0 || port >= 0xffff){
usage("illegal port:", arg);
}
- } else if (strncmp(arg, "-h", 2) == 0 || strncmp(arg, "--host=", 7)){
- host = arg + (arg[1] == '-' ? 2 : 7);
+ } else if (strncmp(arg, "-h", 2) == 0 || strncmp(arg, "--host=", 7) == 0){
+ host = arg + (arg[1] == '-' ? 7 : 2);
int length;
int node = toNumber(host, length);
if (length == 0 || host[length] != '.' || node >= 255){
usage("unknown command:", argv[1]);
}
TcpClient client(&logger);
+ printf("connection to %s:%d\n", host, port);
if (client.connect(host, port)){
client.sendAndReceive(buffer);
printf("Received: %s\n", buffer.str());