aboutsummaryrefslogtreecommitdiffstats
path: root/src/socket_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket_util.c')
-rw-r--r--src/socket_util.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/socket_util.c b/src/socket_util.c
index 3f7075ed3..f673d73e9 100644
--- a/src/socket_util.c
+++ b/src/socket_util.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -148,3 +148,18 @@ socket_bind_listen(int domain, int type, int protocol,
return fd;
}
+
+int
+socket_keepalive(int fd)
+{
+ const int reuse = 1;
+
+#ifdef WIN32
+ const char *optval = (const char *)&reuse;
+#else
+ const void *optval = &reuse;
+#endif
+
+ return setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
+ optval, sizeof(reuse));
+}