From 78c95e08a952fa702ed95f69dca0670ca7f9d49e Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 6 Aug 2011 08:37:14 +0800 Subject: [PATCH] Usermode/telnet - Added default port number --- Usermode/Applications/telnet_src/main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Usermode/Applications/telnet_src/main.c b/Usermode/Applications/telnet_src/main.c index d1f8d175..0d12c1cb 100644 --- a/Usermode/Applications/telnet_src/main.c +++ b/Usermode/Applications/telnet_src/main.c @@ -7,7 +7,7 @@ #include #include -#define BUFSIZ 128 +#define BUFSIZ 2048 // === PROTOTYPES === int main(int argc, char *argv[], char *envp[]); @@ -20,9 +20,20 @@ int main(int argc, char *argv[], char *envp[]) int client_running = 1; int bUseReadline = !!argv[3]; // HACK: If third argument is present, use ReadLine tReadline *readline_info; + int port; + + if( argc < 2 || argc > 3 ) { + fprintf(stderr, "Usage: telnet []\n Port defaults to 23\n"); + return 0; + } + + if(argc == 3) + port = atoi(argv[2]); + else + port = 23; // Connect to the remove server - server_fd = OpenTCP( argv[1], atoi(argv[2]) ); + server_fd = OpenTCP( argv[1], port ); if( server_fd == -1 ) { fprintf(stderr, "Unable to create socket\n"); return -1; -- 2.20.1