From: Michael Vrable Date: Fri, 28 Jan 2011 23:48:46 +0000 (-0800) Subject: Update simplestore to use a standard port number. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=806fb6260c0df63b4ff57245cd0f39747797d9e5;p=bluesky.git Update simplestore to use a standard port number. --- diff --git a/bluesky/store-simple.c b/bluesky/store-simple.c index 1b12ab6..fdd5139 100644 --- a/bluesky/store-simple.c +++ b/bluesky/store-simple.c @@ -249,7 +249,7 @@ static gpointer simplestore_new(const gchar *path) /* TODO: Right now we leak this memory. We should probably clean up in * simplestore_destroy, but it's not a big deal. */ - const gchar *host = "127.0.0.1", *port = "8257"; + const gchar *host = "127.0.0.1", *port = "9541"; if (path != NULL) { gchar **target = g_strsplit(path, ":", 0); if (target[0] != NULL) { diff --git a/simplestore/server.c b/simplestore/server.c index 0e2ed4b..07448f1 100644 --- a/simplestore/server.c +++ b/simplestore/server.c @@ -29,6 +29,8 @@ #include #include +#define SIMPLESTORE_PORT 9541 + /* Maximum number of connections the server will queue waiting for us to call * accept(). */ #define TCP_BACKLOG 32 @@ -193,7 +195,7 @@ void cmd_put(int fd, char *path, char *buf, continue; } - printf("Got %zd bytes for object '%s'\n", buf_used, path); + /* printf("Got %zd bytes for object '%s'\n", buf_used, path); */ char *response = "-1\n"; int file = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0600); @@ -322,6 +324,17 @@ int server_init() exit(1); } + int val = 1; + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); + + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = htonl(INADDR_ANY); + server_addr.sin_port = htons(SIMPLESTORE_PORT); + if (bind(fd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { + perror("bind"); + exit(1); + } + if (listen(fd, TCP_BACKLOG) < 0) { perror("listen"); exit(1);