Subject: [Boost-bugs] [Boost C++ Libraries] #9242: I hope i can set reuseaddr property in socket initialization
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-10-12 01:11:39
#9242: I hope i can set reuseaddr property in socket initialization
---------------------------------------+----------------------------
Reporter: wangyijian <wyj163mail@â¦> | Owner: chris_kohlhoff
Type: Support Requests | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
---------------------------------------+----------------------------
in asio\detail\impl\socket_ops.ipp at 1.54 at line 1288.
origianl:
socket_type socket(int af, int type, int protocol,
boost::system::error_code& ec)
I Hope:
socket_type socket(int af, int type, int protocol,
boost::system::error_code& ec, BOOL ReuseAddr)
And this is my modified code for this function:
socket_type socket(int af, int type, int protocol,
boost::system::error_code& ec, BOOL ReuseAddr)
{
clear_last_error();
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
socket_type s = error_wrapper(::WSASocket(af, type, protocol, 0, 0,
WSA_FLAG_OVERLAPPED), ec);
if (s == invalid_socket)
return s;
if (af == AF_INET6)
{
// Try to enable the POSIX default behaviour of having IPV6_V6ONLY set
to
// false. This will only succeed on Windows Vista and later versions
of
// Windows, where a dual-stack IPv4/v6 implementation is available.
DWORD optval = 0;
::setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
reinterpret_cast<const char*>(&optval), sizeof(optval));
}
// I hope add set SO_REUSEADDR
if (ReuseAddr)
{
DWORD optval = 1;
::setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
reinterpret_cast<const char*>(&optval), sizeof(optval));
}
....
}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9242> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC