Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reuse address when firing up the ros2cli daemon. #947

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ros2cli/ros2cli/xmlrpc/local_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import socket
import struct
# Import SimpleXMLRPCRequestHandler to re-export it.
Expand All @@ -32,7 +33,12 @@ def get_local_ipaddrs():

class LocalXMLRPCServer(SimpleXMLRPCServer):

allow_reuse_address = False
# Allow re-binding even if another server instance was recently bound (i.e. we are still in
# TCP TIME_WAIT). This is already the default behavior on Windows, and further SO_REUSEADDR can
# lead to undefined behavior on Windows; see
# https://learn.microsoft.com/en-us/windows/win32/winsock/using-so-reuseaddr-and-so-exclusiveaddruse. # noqa
# So we don't set the option for Windows.
allow_reuse_address = False if os.name == 'nt' else True

def server_bind(self):
# Prevent listening socket from lingering in TIME_WAIT state after close()
Expand Down