diff options
-rw-r--r-- | pd_server.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pd_server.c b/pd_server.c index 80fcb4f..829a6f7 100644 --- a/pd_server.c +++ b/pd_server.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> @@ -29,12 +30,17 @@ int pay(int a, int b) int main(int argc, char *argv[]) { - int sock, player[2], read_fd; + int sock, player[2]; struct sockaddr_in serv_addr; int port = 8068; - int rounds, i; + int a_payment = 0, b_payment = 0, rounds, i; int optval = 1; + if (argc < 2) { + fprintf(stderr, "usage: %s number-of-rounds\n", argv[0]); + exit(EXIT_FAILURE); + } + rounds = atoi(argv[1]); sock = socket(AF_INET, SOCK_STREAM, 0); @@ -56,7 +62,6 @@ main(int argc, char *argv[]) for (i = 0; i < 2; ++i) { player[i] = accept(sock, NULL, NULL); } - int a_payment = 0, b_payment = 0; for (i = 0; i < rounds; ++i) { char a, b; read(player[0], &a, 1); |