mirror of https://github.com/mpv-player/mpv
optionally reuse the socket if -reuse-socket is selected; patch by Yong Hwan (sio4 users sf net) simplified by me
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22491 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
195ebfbef8
commit
2cefb53a76
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue