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

Update receiver_socket_udp.py #51

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ receiver.stop()
The usage of the receiver is simpler than the sender.
The `sACNreceiver` can be initialized with the following parameters:
* `bind_address: str`: Provide an IP-Address to bind to if you want to receive multicast packets from a specific interface.
_Note:_ This parameter is ignored on Linux when binding the socket to an address, but is used in subscribing the
multicast group to a correct interface. If you have multiple interfaces within your system you will need to
specify this parameter to ensure the multicast group join is completed on the correct interface and you receive
sACN traffic.
* `bind_port: int`: Default: 5568. It is not recommended to change this value!
Only use when you are know what you are doing!

Expand Down
7 changes: 6 additions & 1 deletion sacn/receiving/receiver_socket_udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import socket
import threading
import time
import platform
from sacn.receiving.receiver_socket_base import ReceiverSocketBase, ReceiverSocketListener

THREAD_NAME = 'sACN input/receiver thread'
Expand All @@ -26,7 +27,11 @@ def __init__(self, listener: ReceiverSocketListener, bind_address: str, bind_por
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
except socket.error: # Not all systems support multiple sockets on the same port and interface
pass
self._socket.bind((self._bind_address, self._bind_port))
os_name = platform.system()
if os_name == "Linux":
self._socket.bind(("", self._bind_port))
else:
self._socket.bind((self._bind_address, self._bind_port))
self._logger.info(f'Bind receiver socket to IP: {self._bind_address} port: {self._bind_port}')

def start(self):
Expand Down
Loading