[MPlayer-cvslog] r22491 - in trunk: cfg-common.h stream/udp.c
nicodvb
subversion at mplayerhq.hu
Thu Mar 8 21:47:10 CET 2007
Author: nicodvb
Date: Thu Mar 8 21:47:10 2007
New Revision: 22491
Modified:
trunk/cfg-common.h
trunk/stream/udp.c
Log:
optionally reuse the socket if -reuse-socket is selected; patch by Yong Hwan (sio4 users sf net) simplified by me
Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h (original)
+++ trunk/cfg-common.h Thu Mar 8 21:47:10 2007
@@ -58,6 +58,8 @@
{"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"prefer-ipv4", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+ {"reuse-socket", &reuse_socket, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
+ {"noreuse-socket", &reuse_socket, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
#ifdef HAVE_AF_INET6
{"prefer-ipv6", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, NULL},
#else
@@ -368,6 +370,7 @@ extern char *cookies_file;
extern int network_prefer_ipv4;
extern int network_ipv4_only_proxy;
+extern int reuse_socket;
#endif
Modified: trunk/stream/udp.c
==============================================================================
--- trunk/stream/udp.c (original)
+++ trunk/stream/udp.c Thu Mar 8 21:47:10 2007
@@ -43,6 +43,8 @@
#include "url.h"
#include "udp.h"
+int reuse_socket=0;
+
/* Start listening on a UDP port. If multicast, join the group. */
int
udp_open_socket (URL_t *url)
@@ -55,6 +57,7 @@ udp_open_socket (URL_t *url)
struct ip_mreq mcast;
struct timeval tv;
struct hostent *hp;
+ int reuse=reuse_socket;
mp_msg (MSGT_NETWORK, MSGL_V,
"Listening for traffic on %s:%d ...\n", url->hostname, url->port);
@@ -98,6 +101,9 @@ udp_open_socket (URL_t *url)
server_address.sin_family = AF_INET;
server_address.sin_port = htons (url->port);
+ if(reuse_socket && setsockopt(socket_server_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)))
+ mp_msg(MSGT_NETWORK, MSGL_ERR, "SO_REUSEADDR failed! ignore.\n");
+
if (bind (socket_server_fd, (struct sockaddr *) &server_address,
sizeof (server_address)) == -1)
{
More information about the MPlayer-cvslog
mailing list