Subject: [Boost-bugs] [Boost C++ Libraries] #7302: Accepted socket local_endpoint() method and peer end point after boost::asio::ip::tcp::acceptor::accept() produces an IPv6 address when a client connected using an IPv4 address.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-30 10:09:50
#7302: Accepted socket local_endpoint() method and peer end point after
boost::asio::ip::tcp::acceptor::accept() produces an IPv6 address when a
client connected using an IPv4 address.
---------------------------------------------------+------------------------
Reporter: Radboud Platvoet <radboudp@â¦> | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.49.0 | Severity: Showstopper
Keywords: local_endpoint address_v6 address_v4 |
---------------------------------------------------+------------------------
Accepted socket local_endpoint() method and peer end point after
boost::asio::ip::tcp::acceptor::accept() produces an IPv6 address when a
client connected using an IPv4 address. They should have produced an end
point with an IPv4 address. The IPv6 address is filled with IPv4
information.
Secondly: Acceptor local end point contains an IPv6 address while it
actually listens on both IPv4 and IPv6! Should be able to retrieve both.
TcpView (sysinternals) shows an IPv4 connection.
The code used in the test was intended to test a TCP port state checker.
There are two tests. Both test start an acceptor that listens on port
"1234".
1) The IPv6 test creates a socket that connects to "localhost" and port
"1234". This test works as expected.
2) The IPv4 test creates a socket that connects to "127.0.0.1" and port
"1234". This test fails.
Test Code follows (look for the comment âNext test fails. The endpoint
returned is IPv6 and should have been IPv4.â):
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!c++
//================================================//
/**
* Implements a UnitTest for the IpMonitor class.
*/
class IpMonitorTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE( IpMonitorTest );
CPPUNIT_TEST(TestAsioIPv6);
CPPUNIT_TEST(TestAsioIPv4);
CPPUNIT_TEST_SUITE_END();
private:
boost::asio::io_service m_oIoService;
boost::shared_ptr<boost::asio::ip::tcp::acceptor> m_shpAcceptor;
boost::shared_ptr<boost::asio::ip::tcp::socket> m_shpServerSocket;
std::auto_ptr<boost::thread> m_apListenerThread;
bool m_bListening;
private:
void StartAccept();
void Accept();
protected:
void TestAsioIPv6();
void TestAsioIPv4();
public:
void setUp();
void tearDown();
public:
IpMonitorTest();
virtual ~IpMonitorTest();
};
boost::asio::ip::tcp::endpoint GetEndPoint(boost::asio::io_service&
oIoService,
const std::string& strService)
{
boost::asio::ip::tcp::resolver::query oQuery(strService);
boost::asio::ip::tcp::resolver::iterator oEndPointIterator;
boost::asio::ip::tcp::resolver oResolver(oIoService);
try
{
// try to resolve the endpoint
oEndPointIterator = oResolver.resolve(oQuery);
}
catch (const boost::system::system_error& e)
{
ThrowExceptionStreamFFL("Failed to resolve " << strService <<
" to port number. Error: " << e.what());
}
boost::asio::ip::tcp::endpoint oEndPoint = *oEndPointIterator;
return oEndPoint;
}
void IpMonitorTest::StartAccept()
{
// Run start accept in a separate thread.
m_bListening = false;
m_apListenerThread.reset(new
boost::thread(boost::bind(&IpMonitorTest::Accept, this)));
boost::this_thread::yield();
// Wait for the thread to be started...
while (! m_bListening)
{
boost::this_thread::sleep(boost::posix_time::millisec(100));
}
boost::this_thread::sleep(boost::posix_time::millisec(100));
}
void IpMonitorTest::Accept()
{
// async_accept will accept the next incoming connection and then call
// the provided boost binded method: HandleAccept
boost::asio::ip::tcp::endpoint oPeer;
boost::system::error_code oError;
m_bListening = true;
m_shpAcceptor->accept(*m_shpServerSocket, oPeer, oError);
// Error during accept?
if (oError)
{
m_shpServerSocket.reset();
}
}
#define HOST "localhost"
#define IPv4ADDRESS "127.0.0.1"
#define SERVICE "1234"
void IpMonitorTest::TestAsioIPv6() // This test works well.
{
try
{
{
// IPv6 test...
// Create a server...
CPPUNIT_ASSERT_NO_THROW(m_shpAcceptor.reset(
new boost::asio::ip::tcp::acceptor(m_oIoService,
GetEndPoint(m_oIoService, SERVICE))));
LIB_PROCESS::TcpState eState = LIB_PROCESS::TCP_NO_STATE;
// Is actually listening on both IPv4 and IPv6.
// local endpoint reports only v6.
CPPUNIT_ASSERT(m_shpAcceptor->local_endpoint().address().is_v6());
eState =
LIB_PROCESS::IpMonitor::WaitForTcp(m_shpAcceptor->local_endpoint(),
boost::posix_time::minutes(1),
~(LIB_PROCESS::TCP_LISTEN));
CPPUNIT_ASSERT_EQUAL(eState, LIB_PROCESS::TCP_LISTEN);
// Create a socket that the server will accept on.
CPPUNIT_ASSERT_NO_THROW(m_shpServerSocket.reset(
new boost::asio::ip::tcp::socket(m_oIoService)));
// Start accepting
StartAccept();
// Create a client socket
boost::asio::ip::tcp::socket
oClientSocket(m_oIoService);
// Connect to host name resolves to IPv6 address and IPv6
connection
boost::asio::ip::tcp::resolver::query oQuery(HOST, SERVICE);
boost::asio::ip::tcp::resolver::iterator oEndPointIterator;
boost::asio::ip::tcp::resolver
oResolver(m_oIoService);
// try to resolve the endpoint
oEndPointIterator = oResolver.resolve(oQuery);
boost::asio::ip::tcp::endpoint oEndPoint = *oEndPointIterator;
oClientSocket.connect(oEndPoint);
eState = LIB_PROCESS::TCP_NO_STATE;
CPPUNIT_ASSERT(oClientSocket.local_endpoint().address().is_v6());
eState =
LIB_PROCESS::IpMonitor::WaitForTcp(oClientSocket.local_endpoint(),
boost::posix_time::minutes(1),
~(LIB_PROCESS::TCP_ESTAB));
CPPUNIT_ASSERT_EQUAL(eState, LIB_PROCESS::TCP_ESTAB);
CPPUNIT_ASSERT(m_shpServerSocket.get() != 0);
eState = LIB_PROCESS::TCP_NO_STATE;
CPPUNIT_ASSERT(m_shpServerSocket->local_endpoint().address().is_v6());
eState =
LIB_PROCESS::IpMonitor::WaitForTcp(m_shpServerSocket->local_endpoint(),
boost::posix_time::minutes(1),
~(LIB_PROCESS::TCP_ESTAB));
CPPUNIT_ASSERT_EQUAL(eState, LIB_PROCESS::TCP_ESTAB);
m_shpAcceptor.reset();
m_shpServerSocket.reset();
}
}
catch(const SDU_EXCEPTION::Exception& e)
{
m_shpAcceptor.reset();
m_shpServerSocket.reset();
CPPUNIT_FAIL(e.what());
}
m_shpAcceptor.reset();
m_shpServerSocket.reset();
}
void IpMonitorTest::TestAsioIPv4() // This test fails when cheking the
server local end point
{
try
{
{
// IPv4 test...
// Create a server...
CPPUNIT_ASSERT_NO_THROW(m_shpAcceptor.reset(
new boost::asio::ip::tcp::acceptor(m_oIoService,
GetEndPoint(m_oIoService, SERVICE))));
LIB_PROCESS::TcpState eState = LIB_PROCESS::TCP_NO_STATE;
// Is actually listening on both IPv4 and IPv6.
// local endpoint reports only v6.
CPPUNIT_ASSERT(m_shpAcceptor->local_endpoint().address().is_v6());
eState =
LIB_PROCESS::IpMonitor::WaitForTcp(m_shpAcceptor->local_endpoint(),
boost::posix_time::minutes(1),
~(LIB_PROCESS::TCP_LISTEN));
CPPUNIT_ASSERT_EQUAL(eState, LIB_PROCESS::TCP_LISTEN);
// Create a socket that the server will accept on.
CPPUNIT_ASSERT_NO_THROW(m_shpServerSocket.reset(
new boost::asio::ip::tcp::socket(m_oIoService)));
// Start accepting
StartAccept();
// Create a client socket
boost::asio::ip::tcp::socket
oClientSocket(m_oIoService);
// Connect to IPv4 address resolves to IPv4 address and IPv4
connection.
boost::asio::ip::tcp::resolver::query oQuery(IPv4ADDRESS,
SERVICE);
boost::asio::ip::tcp::resolver::iterator oEndPointIterator;
boost::asio::ip::tcp::resolver
oResolver(m_oIoService);
// try to resolve the endpoint
oEndPointIterator = oResolver.resolve(oQuery);
boost::asio::ip::tcp::endpoint oEndPoint = *oEndPointIterator;
oClientSocket.connect(oEndPoint);
eState = LIB_PROCESS::TCP_NO_STATE;
CPPUNIT_ASSERT(oClientSocket.local_endpoint().address().is_v4());
eState =
LIB_PROCESS::IpMonitor::WaitForTcp(oClientSocket.local_endpoint(),
boost::posix_time::minutes(1),
~(LIB_PROCESS::TCP_ESTAB));
CPPUNIT_ASSERT_EQUAL(eState, LIB_PROCESS::TCP_ESTAB);
CPPUNIT_ASSERT(m_shpServerSocket.get() != 0);
eState = LIB_PROCESS::TCP_NO_STATE;
// Next test fails. The endpoint returned is IPv6 and should have
been IPv4.
CPPUNIT_ASSERT(m_shpServerSocket->local_endpoint().address().is_v4());
eState =
LIB_PROCESS::IpMonitor::WaitForTcp(m_shpServerSocket->local_endpoint(),
boost::posix_time::minutes(1),
~(LIB_PROCESS::TCP_ESTAB));
CPPUNIT_ASSERT_EQUAL(eState, LIB_PROCESS::TCP_ESTAB);
m_shpAcceptor.reset();
m_shpServerSocket.reset();
}
}
catch(const SDU_EXCEPTION::Exception& e)
{
m_shpAcceptor.reset();
m_shpServerSocket.reset();
CPPUNIT_FAIL(e.what());
}
m_shpAcceptor.reset();
m_shpServerSocket.reset();
}
//================================================//
}}}
}}}
Debug info:
Acceptor local end point data for IPv6 test (while it actually listens on
both IPv4 and IPv6):
{{{
- oEndPoint {impl_={...} } const
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x02e6eade "" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x02e6eade "" char [14]
+ v4 {sin_family=23 sin_port=53764 sin_addr={...} ...}
sockaddr_in
- v6 {sin6_family=23 sin6_port=53764 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 53764 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x02e6eae4 "" Word=0x02e6eae4 "" } in6_addr
::<unnamed-type-u>
- Byte 0x02e6eae4 "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 0 unsigned char
[11] 0 unsigned char
[12] 0 unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 0 unsigned char
+ Word 0x02e6eae4 "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6188 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
}}}
Peer local end point data for IPv6 test (in method void
IpMonitorTest::Accept()):
{{{
- oPeer {impl_={...} }
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x0257f38a "" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x0257f38a "" char [14]
+ v4 {sin_family=23 sin_port=21968 sin_addr={...} ...}
sockaddr_in
- v6 {sin6_family=23 sin6_port=21968 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 21968 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x0257f390 "" Word=0x0257f390 "" } in6_addr
::<unnamed-type-u>
- Byte 0x0257f390 "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 0 unsigned char
[11] 0 unsigned char
[12] 0 unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 1 '' unsigned char
+ Word 0x0257f390 "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6188 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:1]:1234
[0:0:0:0:0:0:0:1]:53333 ESTABLISHED
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:1]:53333
[0:0:0:0:0:0:0:1]:1234 ESTABLISHED
}}}
Client local end point data for IPv6 test:
{{{
- oEndPoint {impl_={...} } const
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x02e6efca "" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x02e6efca "" char [14]
+ v4 {sin_family=23 sin_port=21968 sin_addr={...} ...}
sockaddr_in
- v6 {sin6_family=23 sin6_port=21968 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 21968 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x02e6efd0 "" Word=0x02e6efd0 "" } in6_addr
::<unnamed-type-u>
- Byte 0x02e6efd0 "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 0 unsigned char
[11] 0 unsigned char
[12] 0 unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 1 '' unsigned char
+ Word 0x02e6efd0 "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6188 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:1]:1234
[0:0:0:0:0:0:0:1]:53333 ESTABLISHED
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:1]:53333
[0:0:0:0:0:0:0:1]:1234 ESTABLISHED
}}}
Server local end point data for IPv6 test:
{{{
- oEndPoint {impl_={...} } const
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x02e6f286 "" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x02e6f286 "" char [14]
+ v4 {sin_family=23 sin_port=53764 sin_addr={...} ...}
sockaddr_in
- v6 {sin6_family=23 sin6_port=53764 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 53764 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x02e6f28c "" Word=0x02e6f28c "" } in6_addr
::<unnamed-type-u>
- Byte 0x02e6f28c "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 0 unsigned char
[11] 0 unsigned char
[12] 0 unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 1 '' unsigned char
+ Word 0x02e6f28c "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6188 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:1]:1234
[0:0:0:0:0:0:0:1]:53333 ESTABLISHED
ProcessUnittest.exe:6188 TCPV6 [0:0:0:0:0:0:0:1]:53333
[0:0:0:0:0:0:0:1]:1234 ESTABLISHED
}}}
Acceptor local end point data for IPv4 test:
{{{
- oEndPoint {impl_={...} } const
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x0409ebe6 "" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x0409ebe6 "" char [14]
+ v4 {sin_family=23 sin_port=53764 sin_addr={...} ...}
sockaddr_in
- v6 {sin6_family=23 sin6_port=53764 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 53764 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x0409ebec "" Word=0x0409ebec "" } in6_addr
::<unnamed-type-u>
- Byte 0x0409ebec "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 0 unsigned char
[11] 0 unsigned char
[12] 0 unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 0 unsigned char
+ Word 0x0409ebec "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6228 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6228 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
}}}
Peer local end point data for IPv4 test (in method void
IpMonitorTest::Accept()):
This should have been a IPv4 address but sa_family reports 23 (IPv6). You
can also see the IPv4 info in the IPv6 bytes. Bytes 12 â 14 contain 127,
0, 0 and 1. The IP address that was connected to!
{{{
- oPeer {impl_={...} }
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x028cf8d2 "ÃÃ" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x028cf8d2 "ÃÃ" char [14]
- v4 {sin_family=23 sin_port=52688 sin_addr={...} ...}
sockaddr_in
sin_family 23 unsigned short
sin_port 52688 unsigned short
- sin_addr {S_un={...} } in_addr
- S_un {S_un_b={...} S_un_w={...} S_addr=0 } in_addr
::<unnamed-type-S_un>
- S_un_b {s_b1=0 s_b2=0 s_b3=0 ...} in_addr::<unnamed-type-
S_un>::<unnamed-type-S_un_b>
s_b1 0 unsigned char
s_b2 0 unsigned char
s_b3 0 unsigned char
s_b4 0 unsigned char
+ S_un_w {s_w1=0 s_w2=0 } in_addr::<unnamed-type-S_un
>::<unnamed-type-S_un_w>
S_addr 0 unsigned long
+ sin_zero 0x028cf8d8 "" char [8]
- v6 {sin6_family=23 sin6_port=52688 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 52688 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x028cf8d8 "" Word=0x028cf8d8 "" } in6_addr
::<unnamed-type-u>
- Byte 0x028cf8d8 "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 255 'ÿ' unsigned char
[11] 255 'ÿ' unsigned char
[12] 127 '' unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 1 '' unsigned char
+ Word 0x028cf8d8 "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6228 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6228 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
ProcessUnittest.exe:6228 TCP 127.0.0.1:1234
127.0.0.1:53453 ESTABLISHED
ProcessUnittest.exe:6228 TCP 127.0.0.1:53453 127.0.0.1:1234
ESTABLISHED
}}}
Client local end point data for IPv4 test (correct, sa_family is 2):
{{{
- oEndPoint {impl_={...} } const
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=2 sa_data=0x0412ed72 "ÃÃ" } sockaddr
sa_family 2 unsigned short
+ sa_data 0x0412ed72 "ÃÃ" char [14]
- v4 {sin_family=2 sin_port=52688 sin_addr={...} ...}
sockaddr_in
sin_family 2 unsigned short
sin_port 52688 unsigned short
- sin_addr {S_un={...} } in_addr
- S_un {S_un_b={...} S_un_w={...} S_addr=16777343 }
in_addr::<unnamed-type-S_un>
- S_un_b {s_b1='' s_b2=0 s_b3=0 ...} in_addr::<unnamed-
type-S_un>::<unnamed-type-S_un_b>
s_b1 127 '' unsigned char
s_b2 0 unsigned char
s_b3 0 unsigned char
s_b4 1 '' unsigned char
+ S_un_w {s_w1=127 s_w2=256 } in_addr::<unnamed-type-S_un
>::<unnamed-type-S_un_w>
S_addr 16777343 unsigned long
+ sin_zero 0x0412ed78 "" char [8]
+ v6 {sin6_family=2 sin6_port=52688 sin6_flowinfo=16777343
...} sockaddr_in6
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6228 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6228 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
ProcessUnittest.exe:6228 TCP 127.0.0.1:1234
127.0.0.1:53453 ESTABLISHED
ProcessUnittest.exe:6228 TCP 127.0.0.1:53453 127.0.0.1:1234
ESTABLISHED
}}}
Server local end point data for IPv4 test:
Again this should have been a IPv4 address but sa_family reports 23
(IPv6). You can also see the IPv4 info in the IPv6 bytes. Bytes 12 â 14
contain 127, 0, 0 and 1. The IP address that was connected to! (This
actual capture is from one run later than the once above, that is why the
port number is different.)
{{{
- oEndPoint {impl_={...} }
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>
- impl_ {data_={...} }
boost::asio::ip::detail::endpoint
- data_ {base={...} v4={...} v6={...} }
boost::asio::ip::detail::endpoint::data_union
- base {sa_family=23 sa_data=0x0416f212 "" } sockaddr
sa_family 23 unsigned short
+ sa_data 0x0416f212 "" char [14]
- v4 {sin_family=23 sin_port=53764 sin_addr={...} ...}
sockaddr_in
sin_family 23 short
sin_port 53764 unsigned short
- sin_addr {S_un={...} } in_addr
- S_un {S_un_b={...} S_un_w={...} S_addr=0 } in_addr
::<unnamed-type-S_un>
- S_un_b {s_b1=0 s_b2=0 s_b3=0 ...} in_addr::<unnamed-type-
S_un>::<unnamed-type-S_un_b>
s_b1 0 unsigned char
s_b2 0 unsigned char
s_b3 0 unsigned char
s_b4 0 unsigned char
+ S_un_w {s_w1=0 s_w2=0 } in_addr::<unnamed-type-S_un
>::<unnamed-type-S_un_w>
S_addr 0 unsigned long
+ sin_zero 0x0416f218 "" char [8]
- v6 {sin6_family=23 sin6_port=53764 sin6_flowinfo=0 ...}
sockaddr_in6
sin6_family 23 unsigned short
sin6_port 53764 unsigned short
sin6_flowinfo 0 unsigned long
- sin6_addr {u={...} } in6_addr
- u {Byte=0x0416f218 "" Word=0x0416f218 "" } in6_addr
::<unnamed-type-u>
- Byte 0x0416f218 "" unsigned char [16]
[0] 0 unsigned char
[1] 0 unsigned char
[2] 0 unsigned char
[3] 0 unsigned char
[4] 0 unsigned char
[5] 0 unsigned char
[6] 0 unsigned char
[7] 0 unsigned char
[8] 0 unsigned char
[9] 0 unsigned char
[10] 255 'ÿ' unsigned char
[11] 255 'ÿ' unsigned char
[12] 127 '' unsigned char
[13] 0 unsigned char
[14] 0 unsigned char
[15] 1 '' unsigned char
+ Word 0x0416f218 "" unsigned short [8]
sin6_scope_id 0 unsigned long
- sin6_scope_struct {Zone=0 Level=0 Value=0 } SCOPE_ID
Zone 0 unsigned long
Level 0 unsigned long
Value 0 unsigned long
}}}
Sysinternals TcpView at this point:
{{{
ProcessUnittest.exe:6228 TCP 0.0.0.0:1234 0.0.0.0:0
LISTENING
ProcessUnittest.exe:6228 TCPV6 [0:0:0:0:0:0:0:0]:1234
[0:0:0:0:0:0:0:0]:0 LISTENING
ProcessUnittest.exe:6228 TCP 127.0.0.1:1234
127.0.0.1:53453 ESTABLISHED
ProcessUnittest.exe:6228 TCP 127.0.0.1:53453 127.0.0.1:1234
ESTABLISHED
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7302> 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:10 UTC