Skip to content

Commit

Permalink
ntsu::SocketUtil::pair: always set reuseAddress to false
Browse files Browse the repository at this point in the history
  • Loading branch information
smtrfnv authored Jun 11, 2024
1 parent a591a82 commit 81de50a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions groups/nts/ntsu/ntsu_socketutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3997,7 +3997,7 @@ ntsa::Error SocketUtil::pair(ntsa::Handle* client,

error = ntsu::SocketUtil::bind(
ntsa::Endpoint(ntsa::IpEndpoint(ntsa::Ipv4Address::loopback(), 0)),
true,
false,
listener);
if (error) {
return error;
Expand Down Expand Up @@ -4044,7 +4044,7 @@ ntsa::Error SocketUtil::pair(ntsa::Handle* client,

error = ntsu::SocketUtil::bind(
ntsa::Endpoint(ntsa::IpEndpoint(ntsa::Ipv6Address::loopback(), 0)),
true,
false,
listener);
if (error) {
return error;
Expand Down Expand Up @@ -4097,15 +4097,15 @@ ntsa::Error SocketUtil::pair(ntsa::Handle* client,

error = ntsu::SocketUtil::bind(
ntsa::Endpoint(ntsa::IpEndpoint(ntsa::Ipv4Address::loopback(), 0)),
true,
false,
*client);
if (error) {
return error;
}

error = ntsu::SocketUtil::bind(
ntsa::Endpoint(ntsa::IpEndpoint(ntsa::Ipv4Address::loopback(), 0)),
true,
false,
*server);
if (error) {
return error;
Expand Down Expand Up @@ -4153,15 +4153,15 @@ ntsa::Error SocketUtil::pair(ntsa::Handle* client,

error = ntsu::SocketUtil::bind(
ntsa::Endpoint(ntsa::IpEndpoint(ntsa::Ipv6Address::loopback(), 0)),
true,
false,
*client);
if (error) {
return error;
}

error = ntsu::SocketUtil::bind(
ntsa::Endpoint(ntsa::IpEndpoint(ntsa::Ipv6Address::loopback(), 0)),
true,
false,
*server);
if (error) {
return error;
Expand Down Expand Up @@ -5389,7 +5389,7 @@ ntsa::Error SocketUtil::bind(const ntsa::Endpoint& endpoint,
ntsa::Error error;

#if NTSCFG_BUILD_WITH_TRANSPORT_PROTOCOL_LOCAL
const bool isLocal = endpoint.isLocal();
const bool isLocal = endpoint.isLocal();
#else
const bool isLocal = false;
#endif
Expand Down Expand Up @@ -6854,7 +6854,7 @@ ntsa::Error SocketUtil::receive(bsl::size_t* numBytesReceived,
DWORD wsaFlags = 0;

int wsaRecvResult =
WSARecv(socket, &wsaBuf, 1, &wsaNumBytesReceived, &wsaFlags, 0, 0);
WSARecv(socket, &wsaBuf, 1, &wsaNumBytesReceived, &wsaFlags, 0, 0);

if (wsaRecvResult != 0) {
return ntsa::Error(WSAGetLastError());
Expand Down
2 changes: 2 additions & 0 deletions groups/nts/ntsu/ntsu_socketutil.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7330,6 +7330,8 @@ NTSCFG_TEST_CASE(18)
error =
ntsu::SocketUtil::receive(&context, &data, options, server);
NTSCFG_TEST_ASSERT(!error);
NTSCFG_TEST_EQ(context.bytesReceived(), 1);
NTSCFG_TEST_EQ(context.bytesReceivable(), 1);

NTSCFG_TEST_ASSERT(!context.endpoint().isNull());

Expand Down

0 comments on commit 81de50a

Please sign in to comment.