Mercurial > mplayer.hg
changeset 22473:011d1adc0133
optionally reuse the socket if -reuse-socket is selected; patch by Yong Hwan (sio4 users sf net) simplified by me
author | nicodvb |
---|---|
date | Thu, 08 Mar 2007 20:47:10 +0000 |
parents | 55d3b70398d9 |
children | f5c234c87e5f |
files | cfg-common.h stream/udp.c |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-common.h Thu Mar 08 13:45:35 2007 +0000 +++ b/cfg-common.h Thu Mar 08 20:47:10 2007 +0000 @@ -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 int network_prefer_ipv4; extern int network_ipv4_only_proxy; +extern int reuse_socket; #endif
--- a/stream/udp.c Thu Mar 08 13:45:35 2007 +0000 +++ b/stream/udp.c Thu Mar 08 20:47:10 2007 +0000 @@ -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 @@ 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 @@ 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) {