/* 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) {
#include <sys/types.h>
#include <sys/wait.h>
+#define SIMPLESTORE_PORT 9541
+
/* Maximum number of connections the server will queue waiting for us to call
* accept(). */
#define TCP_BACKLOG 32
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);
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);