From 724b4883100609a096d514e7a3d9a3e5dca61182 Mon Sep 17 00:00:00 2001 From: hama Date: Wed, 15 Jun 2016 00:26:04 +0200 Subject: [PATCH] client: option evaluation --- Server/client.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Server/client.cpp b/Server/client.cpp index cd28f7a..71e3d34 100644 --- a/Server/client.cpp +++ b/Server/client.cpp @@ -68,13 +68,13 @@ int main (int argc, char **argv) { 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){ @@ -119,6 +119,7 @@ int main (int argc, char **argv) { 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()); -- 2.39.5