Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stunserver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Stunserver
Commits
a6b079a9
Commit
a6b079a9
authored
Feb 13, 2026
by
John Selbie
Committed by
GitHub
Feb 13, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Introducing the SO_REUSEADDR flag. Client only for now (#69)"
This reverts commit
95bd802f
.
parent
a337ffc6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
27 deletions
+15
-27
client/clientmain.cpp
client/clientmain.cpp
+2
-2
networkutils/stunsocket.cpp
networkutils/stunsocket.cpp
+6
-18
networkutils/stunsocket.h
networkutils/stunsocket.h
+3
-3
server/server.cpp
server/server.cpp
+1
-1
server/tcpserver.cpp
server/tcpserver.cpp
+1
-1
testcode/testrecvfromex.cpp
testcode/testrecvfromex.cpp
+2
-2
No files found.
client/clientmain.cpp
View file @
a6b079a9
...
@@ -327,7 +327,7 @@ void TcpClientLoop(StunClientLogicConfig& config, ClientSocketConfig& socketconf
...
@@ -327,7 +327,7 @@ void TcpClientLoop(StunClientLogicConfig& config, ClientSocketConfig& socketconf
{
{
stunsocket
.
Close
();
stunsocket
.
Close
();
hr
=
stunsocket
.
TCPInit
(
socketconfig
.
addrLocal
,
RolePP
,
true
,
true
);
hr
=
stunsocket
.
TCPInit
(
addrLocal
,
RolePP
,
true
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
{
{
Logging
::
LogMsg
(
LL_ALWAYS
,
"Unable to create local socket for TCP connection (hr == %x)"
,
hr
);
Logging
::
LogMsg
(
LL_ALWAYS
,
"Unable to create local socket for TCP connection (hr == %x)"
,
hr
);
...
@@ -474,7 +474,7 @@ HRESULT UdpClientLoop(StunClientLogicConfig& config, const ClientSocketConfig& s
...
@@ -474,7 +474,7 @@ HRESULT UdpClientLoop(StunClientLogicConfig& config, const ClientSocketConfig& s
Chk
(
hr
);
Chk
(
hr
);
}
}
hr
=
stunSocket
.
UDPInit
(
socketconfig
.
addrLocal
,
RolePP
,
false
,
false
);
hr
=
stunSocket
.
UDPInit
(
socketconfig
.
addrLocal
,
RolePP
,
false
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
{
{
Logging
::
LogMsg
(
LL_ALWAYS
,
"Unable to create local socket: (error = x%x)"
,
hr
);
Logging
::
LogMsg
(
LL_ALWAYS
,
"Unable to create local socket: (error = x%x)"
,
hr
);
...
...
networkutils/stunsocket.cpp
View file @
a6b079a9
...
@@ -273,7 +273,7 @@ void CStunSocket::UpdateAddresses()
...
@@ -273,7 +273,7 @@ void CStunSocket::UpdateAddresses()
HRESULT
CStunSocket
::
InitCommon
(
int
socktype
,
const
CSocketAddress
&
addrlocal
,
SocketRole
role
,
bool
fSetReuseFlag
,
bool
fSetReusePortFlag
)
HRESULT
CStunSocket
::
InitCommon
(
int
socktype
,
const
CSocketAddress
&
addrlocal
,
SocketRole
role
,
bool
fSetReuseFlag
)
{
{
int
sock
=
-
1
;
int
sock
=
-
1
;
int
ret
;
int
ret
;
...
@@ -299,19 +299,7 @@ HRESULT CStunSocket::InitCommon(int socktype, const CSocketAddress& addrlocal, S
...
@@ -299,19 +299,7 @@ HRESULT CStunSocket::InitCommon(int socktype, const CSocketAddress& addrlocal, S
ret
=
::
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
fAllow
,
sizeof
(
fAllow
));
ret
=
::
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
fAllow
,
sizeof
(
fAllow
));
ChkIf
(
ret
==
-
1
,
ERRNOHR
);
ChkIf
(
ret
==
-
1
,
ERRNOHR
);
}
}
#ifdef SO_REUSEPORT
if
(
fSetReusePortFlag
)
{
int
fAllow
=
1
;
ret
=
::
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEPORT
,
&
fAllow
,
sizeof
(
fAllow
));
if
(
ret
==
-
1
)
{
Logging
::
LogMsg
(
LL_DEBUG
,
"Warning: Failed to set SO_REUSEPORT option (errno = %d)"
,
errno
);
}
}
#endif
ret
=
bind
(
sock
,
addrlocal
.
GetSockAddr
(),
addrlocal
.
GetSockAddrLength
());
ret
=
bind
(
sock
,
addrlocal
.
GetSockAddr
(),
addrlocal
.
GetSockAddrLength
());
ChkIf
(
ret
==
-
1
,
ERRNOHR
);
ChkIf
(
ret
==
-
1
,
ERRNOHR
);
...
@@ -331,14 +319,14 @@ Cleanup:
...
@@ -331,14 +319,14 @@ Cleanup:
HRESULT
CStunSocket
::
UDPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
,
bool
fSetReusePortFlag
)
HRESULT
CStunSocket
::
UDPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
)
{
{
return
InitCommon
(
SOCK_DGRAM
,
local
,
role
,
fSetReuseFlag
,
fSetReusePortFlag
);
return
InitCommon
(
SOCK_DGRAM
,
local
,
role
,
fSetReuseFlag
);
}
}
HRESULT
CStunSocket
::
TCPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
,
bool
fSetReusePortFlag
)
HRESULT
CStunSocket
::
TCPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
)
{
{
return
InitCommon
(
SOCK_STREAM
,
local
,
role
,
fSetReuseFlag
,
fSetReusePortFlag
);
return
InitCommon
(
SOCK_STREAM
,
local
,
role
,
fSetReuseFlag
);
}
}
networkutils/stunsocket.h
View file @
a6b079a9
...
@@ -30,7 +30,7 @@ private:
...
@@ -30,7 +30,7 @@ private:
CStunSocket
(
const
CStunSocket
&
)
{;}
CStunSocket
(
const
CStunSocket
&
)
{;}
void
operator
=
(
const
CStunSocket
&
)
{;}
void
operator
=
(
const
CStunSocket
&
)
{;}
HRESULT
InitCommon
(
int
socktype
,
const
CSocketAddress
&
addrlocal
,
SocketRole
role
,
bool
fSetReuseFlag
,
bool
fSetReusePortFlag
);
HRESULT
InitCommon
(
int
socktype
,
const
CSocketAddress
&
addrlocal
,
SocketRole
role
,
bool
fSetReuseFlag
);
void
Reset
();
void
Reset
();
...
@@ -65,8 +65,8 @@ public:
...
@@ -65,8 +65,8 @@ public:
void
UpdateAddresses
();
void
UpdateAddresses
();
HRESULT
UDPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
,
bool
fSetReusePortFlag
);
HRESULT
UDPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
);
HRESULT
TCPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
,
bool
fSetReusePortFlag
);
HRESULT
TCPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
,
bool
fSetReuseFlag
);
};
};
typedef
boost
::
shared_ptr
<
CStunSocket
>
CRefCountedStunSocket
;
typedef
boost
::
shared_ptr
<
CStunSocket
>
CRefCountedStunSocket
;
...
...
server/server.cpp
View file @
a6b079a9
...
@@ -57,7 +57,7 @@ HRESULT CStunServer::AddSocket(TransportAddressSet* pTSA, SocketRole role, const
...
@@ -57,7 +57,7 @@ HRESULT CStunServer::AddSocket(TransportAddressSet* pTSA, SocketRole role, const
ASSERT
(
IsValidSocketRole
(
role
));
ASSERT
(
IsValidSocketRole
(
role
));
Chk
(
_arrSockets
[
role
].
UDPInit
(
addrListen
,
role
,
fSetReuseFlag
,
false
));
Chk
(
_arrSockets
[
role
].
UDPInit
(
addrListen
,
role
,
fSetReuseFlag
));
ChkA
(
_arrSockets
[
role
].
EnablePktInfoOption
(
true
));
ChkA
(
_arrSockets
[
role
].
EnablePktInfoOption
(
true
));
...
...
server/tcpserver.cpp
View file @
a6b079a9
...
@@ -179,7 +179,7 @@ HRESULT CTCPStunThread::CreateListenSockets()
...
@@ -179,7 +179,7 @@ HRESULT CTCPStunThread::CreateListenSockets()
{
{
if
(
_tsaListen
.
set
[
r
].
fValid
)
if
(
_tsaListen
.
set
[
r
].
fValid
)
{
{
ChkA
(
_socketListenArray
[
r
].
TCPInit
(
_tsaListen
.
set
[
r
].
addr
,
(
SocketRole
)
r
,
true
,
false
));
ChkA
(
_socketListenArray
[
r
].
TCPInit
(
_tsaListen
.
set
[
r
].
addr
,
(
SocketRole
)
r
,
true
));
_socketTable
[
r
]
=
_socketListenArray
[
r
].
GetSocketHandle
();
_socketTable
[
r
]
=
_socketListenArray
[
r
].
GetSocketHandle
();
ChkA
(
_socketListenArray
[
r
].
SetNonBlocking
(
true
));
ChkA
(
_socketListenArray
[
r
].
SetNonBlocking
(
true
));
ret
=
listen
(
_socketTable
[
r
],
128
);
// 128 - large backlog.
ret
=
listen
(
_socketTable
[
r
],
128
);
// 128 - large backlog.
...
...
testcode/testrecvfromex.cpp
View file @
a6b079a9
...
@@ -70,9 +70,9 @@ HRESULT CTestRecvFromEx::DoTest(bool fIPV6)
...
@@ -70,9 +70,9 @@ HRESULT CTestRecvFromEx::DoTest(bool fIPV6)
// create two sockets listening on INADDR_ANY. One for sending and one for receiving
// create two sockets listening on INADDR_ANY. One for sending and one for receiving
ChkA
(
socketSend
.
UDPInit
(
addrAny
,
RolePP
,
false
,
false
));
ChkA
(
socketSend
.
UDPInit
(
addrAny
,
RolePP
,
false
));
ChkA
(
socketRecv
.
UDPInit
(
addrAny
,
RolePP
,
false
,
false
));
ChkA
(
socketRecv
.
UDPInit
(
addrAny
,
RolePP
,
false
));
socketRecv
.
EnablePktInfoOption
(
true
);
socketRecv
.
EnablePktInfoOption
(
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment