From 570df2e4f2d189dfaba63d249e8a080da2448b58 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Thu, 6 Oct 2005 12:20:33 +0000 Subject: [PATCH] Don't hard-code port numbers, let the user specify them. --- tools/tools/netrate/http/http.c | 9 ++++----- tools/tools/netrate/httpd/httpd.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/tools/netrate/http/http.c b/tools/tools/netrate/http/http.c index cd133e018674..17c7d6dd4bae 100644 --- a/tools/tools/netrate/http/http.c +++ b/tools/tools/netrate/http/http.c @@ -48,7 +48,6 @@ #define THREADS 128 #define SECONDS 20 #define BUFFER (48*1024) -#define HTTP 8000 #define QUIET 1 struct http_worker_description { @@ -153,15 +152,15 @@ main(int argc, char *argv[]) u_int64_t total; int i; - if (argc != 3) - errx(-1, "usage: http [IP] [PATH]"); + if (argc != 4) + errx(-1, "usage: http [ip] [port] [path]"); bzero(&sin, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; - sin.sin_port = htons(HTTP); sin.sin_addr.s_addr = inet_addr(argv[1]); - path = argv[2]; + sin.sin_port = htons(atoi(argv[2])); + path = argv[3]; /* * Do one test retrieve so we can report the error from it, if any. diff --git a/tools/tools/netrate/httpd/httpd.c b/tools/tools/netrate/httpd/httpd.c index 549fe4a8bff5..a066c966a38a 100644 --- a/tools/tools/netrate/httpd/httpd.c +++ b/tools/tools/netrate/httpd/httpd.c @@ -47,7 +47,6 @@ */ #define THREADS 128 #define BUFFER (48*1024) -#define HTTP 8000 #define HTTP_OK "HTTP/1.1 200 OK\n" #define HTTP_SERVER "Server rwatson_httpd/1.0 (FreeBSD)\n" @@ -128,8 +127,8 @@ main(int argc, char *argv[]) struct sockaddr_in sin; int i; - if (argc != 2) - errx(-1, "usage: http [PATH]"); + if (argc != 3) + errx(-1, "usage: http [port] [path]"); listen_sock = socket(PF_INET, SOCK_STREAM, 0); if (listen_sock < 0) @@ -138,9 +137,9 @@ main(int argc, char *argv[]) bzero(&sin, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; - sin.sin_port = htons(HTTP); + sin.sin_port = htons(atoi(argv[1])); - path = argv[1]; + path = argv[2]; data_file = open(path, O_RDONLY); if (data_file < 0) err(-1, "open: %s", path);