From f1ce177fba026e2ec90e7ea3e0cd4a1ca8d0e2e2 Mon Sep 17 00:00:00 2001 From: John Carr Date: Wed, 8 Apr 1992 15:44:47 +0000 Subject: [PATCH] Allow command line option to select port number git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2274 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/sample/sclient/sclient.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/appl/sample/sclient/sclient.c b/src/appl/sample/sclient/sclient.c index 9bb015af6..b3a243799 100644 --- a/src/appl/sample/sclient/sclient.c +++ b/src/appl/sample/sclient/sclient.c @@ -66,11 +66,11 @@ char *argv[]; krb5_ap_rep_enc_part *rep_ret; short xmitlen; - if (argc != 2) { - fprintf(stderr, "usage: %s \n",argv[0]); + if (argc != 2 && argc != 3) { + fprintf(stderr, "usage: %s [port]\n",argv[0]); exit(1); } - + krb5_init_ets(); (void) signal(SIGPIPE, SIG_IGN); @@ -82,17 +82,22 @@ char *argv[]; /* clear out the structure first */ (void) memset((char *)&sin, 0, sizeof(sin)); - /* find the port number for knetd */ - sp = getservbyname(SAMPLE_SERVICE, "tcp"); - if (!sp) { - fprintf(stderr, - "unknown service %s/tcp; check /etc/services\n", - SAMPLE_SERVICE); - exit(1); + if (argc == 3) { + sin.sin_family = AF_INET; + sin.sin_port = htons(atoi(argv[2])); + } else { + /* find the port number for knetd */ + sp = getservbyname(SAMPLE_SERVICE, "tcp"); + if (!sp) { + fprintf(stderr, + "unknown service %s/tcp; check /etc/services\n", + SAMPLE_SERVICE); + exit(1); + } + /* copy the port number */ + sin.sin_port = sp->s_port; + sin.sin_family = AF_INET; } - /* copy the port number */ - sin.sin_port = sp->s_port; - sin.sin_family = AF_INET; /* look up the server host */ hp = gethostbyname(argv[1]); -- 2.26.2