From 940bf1a32c4c297a6838192ff4268ab5459713b7 Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Sat, 5 Dec 2020 18:48:49 +0000 Subject: [PATCH] fix help return and detail err --- server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server.c b/server.c index b162146..0b89d1c 100644 --- a/server.c +++ b/server.c @@ -210,17 +210,21 @@ int parse_args(int argc,const char * argv[] , in_port_t * port){ if (strcmp(opt,"-h") == 0 || strcmp(opt,"--help") == 0) { help(argv[0]); - return 2; + return 0; } else if(strcmp(opt,"-p") == 0 || strcmp(opt,"--port") == 0){ if (pos < argc){ const char * value = argv[pos++]; *port = atoi(value); if (port == 0){ // either not number or zero + fprintf(stderr,"argument is either not number or zero\n"); return 2; } } - else return 2; //failed to find argument. + else{ + fprintf(stderr,"need argument\n"); + return 2; //failed to find argument. + } } } return 0;