summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-09 09:46:01 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-09 09:46:01 +0100
commit340fa59b67dfcc850717c7453f75e5126eaeb1e9 (patch)
treed122ea6388481a714bf10a538f52891ee9573f99
parenta95b484414d17f52eb5ece6d144fff340c97f1c0 (diff)
downloadwbs-340fa59b67dfcc850717c7453f75e5126eaeb1e9.tar.gz
wbs-340fa59b67dfcc850717c7453f75e5126eaeb1e9.tar.bz2
wbs-340fa59b67dfcc850717c7453f75e5126eaeb1e9.zip
pd_server: Some code cleanup
-rw-r--r--pd_server.c11
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);