summaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'server.c')
-rw-r--r--server.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/server.c b/server.c
index 0298491..3cc2398 100644
--- a/server.c
+++ b/server.c
@@ -10,6 +10,9 @@
#include <poll.h>
#include <errno.h>
#include <sched.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
#include "main.h"
#include "uring.h"
@@ -212,7 +215,7 @@ static bool
server_local_open(struct cfg *cfg, struct server *scfg, struct server_local *local)
{
int sfd;
- int enable = 1;
+ int option;
int r;
sfd = socket(local->addr.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0);
@@ -221,11 +224,25 @@ server_local_open(struct cfg *cfg, struct server *scfg, struct server_local *loc
goto out;
}
- if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) < 0) {
+ option = true;
+ if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) < 0) {
perror("setsockopt");
goto out;
}
+ /* The MC protocol expects the client to send data first */
+ /* FIXME: could make this configurable */
+ option = true;
+ if (setsockopt(sfd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &option, sizeof(option)) < 0)
+ perror("setsockopt");
+
+ /* FIXME: could make this configurable */
+ option = true;
+ if (setsockopt(sfd, IPPROTO_IP, IP_FREEBIND, &option, sizeof(option)) < 0)
+ perror("setsockopt");
+
+ socket_set_gaming_options(cfg, sfd);
+
r = bind(sfd, (struct sockaddr *)&local->addr.storage, local->addr.addrlen);
if (r < 0) {
perror("bind");