Do not require exclusive bind of udp sockets (#154)
This commit is contained in:
parent
97fc9828f0
commit
4f9bbe3769
1
AUTHORS
1
AUTHORS
|
@ -17,4 +17,5 @@ Anders Hasselqvist <anders.hasselqvist@gmail.com>
|
||||||
Google Inc. <*@google.com>
|
Google Inc. <*@google.com>
|
||||||
Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
|
Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
|
||||||
Philo Inc. <*@philo.com>
|
Philo Inc. <*@philo.com>
|
||||||
|
Sergio Ammirata <sergio@ammirata.net>
|
||||||
The Chromium Authors <*@chromium.org>
|
The Chromium Authors <*@chromium.org>
|
||||||
|
|
|
@ -30,4 +30,5 @@ Joey Parrish <joeyparrish@google.com>
|
||||||
Kongqun Yang <kqyang@google.com>
|
Kongqun Yang <kqyang@google.com>
|
||||||
Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
|
Leandro Moreira <leandro.ribeiro.moreira@gmail.com>
|
||||||
Rintaro Kuroiwa <rkuroiwa@google.com>
|
Rintaro Kuroiwa <rkuroiwa@google.com>
|
||||||
|
Sergio Ammirata <sergio@ammirata.net>
|
||||||
Thomas Inskip <tinskip@google.com>
|
Thomas Inskip <tinskip@google.com>
|
||||||
|
|
|
@ -187,6 +187,14 @@ bool UdpFile::Open() {
|
||||||
local_sock_addr.sin_family = AF_INET;
|
local_sock_addr.sin_family = AF_INET;
|
||||||
local_sock_addr.sin_port = htons(dest_port);
|
local_sock_addr.sin_port = htons(dest_port);
|
||||||
local_sock_addr.sin_addr.s_addr = htonl(dest_addr);
|
local_sock_addr.sin_addr.s_addr = htonl(dest_addr);
|
||||||
|
// We do not need to require exclusive bind of udp sockets
|
||||||
|
const int optval = 1;
|
||||||
|
if (setsockopt(new_socket.get(), SOL_SOCKET, SO_REUSEADDR, &optval,
|
||||||
|
sizeof(optval)) < 0) {
|
||||||
|
LOG(ERROR)
|
||||||
|
<< "Could not apply the SO_REUSEADDR property to the UDP socket";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (bind(new_socket.get(),
|
if (bind(new_socket.get(),
|
||||||
reinterpret_cast<struct sockaddr*>(&local_sock_addr),
|
reinterpret_cast<struct sockaddr*>(&local_sock_addr),
|
||||||
sizeof(local_sock_addr))) {
|
sizeof(local_sock_addr))) {
|
||||||
|
|
Loading…
Reference in New Issue