diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-10-06 12:20:33 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-10-06 12:20:33 +0000 |
commit | 5770eb4200f7996e417606793ee507a49b4249cf (patch) | |
tree | d8aa73b0b30ed48b483542949edf5db839e0ce5c /tools | |
parent | 0596f6f56bc25179fc601b9fda6aa6503d2cdf98 (diff) | |
download | FreeBSD-src-5770eb4200f7996e417606793ee507a49b4249cf.zip FreeBSD-src-5770eb4200f7996e417606793ee507a49b4249cf.tar.gz |
Don't hard-code port numbers, let the user specify them.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/netrate/http/http.c | 9 | ||||
-rw-r--r-- | 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 cd133e0..17c7d6d 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 549fe4a..a066c96 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); |