Don't hard-code port numbers, let the user specify them.

This commit is contained in:
Robert Watson 2005-10-06 12:20:33 +00:00
parent 2dfc7d008b
commit 570df2e4f2
2 changed files with 8 additions and 10 deletions

View File

@ -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.

View File

@ -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);