Skip to content

Commit 9956d8b

Browse files
REUSE PORT option not supported on windows
1 parent 029f7f2 commit 9956d8b

File tree

1 file changed

+6
-3
lines changed
  • can/interfaces/udp_multicast

1 file changed

+6
-3
lines changed

can/interfaces/udp_multicast/bus.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import errno
22
import logging
3+
import platform
34
import select
45
import socket
56
import struct
67
import time
78
import warnings
8-
import platform
99
from typing import List, Optional, Tuple, Union
1010

1111
import can
@@ -22,7 +22,7 @@
2222
ioctl_supported = False
2323
pass
2424

25-
# All ioctls aren't supported on MacOS.
25+
# All ioctls aren't supported on MacOS.
2626
is_macos = platform.system() == "Darwin"
2727

2828
log = logging.getLogger(__name__)
@@ -277,7 +277,10 @@ def _create_socket(self, address_family: socket.AddressFamily) -> socket.socket:
277277

278278
# Allow multiple programs to access that address + port
279279
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
280-
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
280+
281+
# Option not supported on Windows.
282+
if hasattr(socket, "SO_REUSEPORT"):
283+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
281284

282285
# set how to receive timestamps
283286
try:

0 commit comments

Comments
 (0)