From ce4091c48a79c0d908809f7d0f3db981617b036d Mon Sep 17 00:00:00 2001 From: Hadley Rich Date: Wed, 16 Aug 2023 11:53:07 +1200 Subject: [PATCH] Allow setting source address --- stupidArtnet/StupidArtnet.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stupidArtnet/StupidArtnet.py b/stupidArtnet/StupidArtnet.py index a4d5ec5..52d5e3c 100644 --- a/stupidArtnet/StupidArtnet.py +++ b/stupidArtnet/StupidArtnet.py @@ -20,7 +20,7 @@ class StupidArtnet(): UDP_PORT = 6454 def __init__(self, target_ip='127.0.0.1', universe=0, packet_size=512, fps=30, - even_packet_size=True, broadcast=False): + even_packet_size=True, broadcast=False, source_address=None): """Initializes Art-Net Client. Args: @@ -57,6 +57,11 @@ def __init__(self, target_ip='127.0.0.1', universe=0, packet_size=512, fps=30, self.socket_client.setsockopt( socket.SOL_SOCKET, socket.SO_BROADCAST, 1) + if source_address: + self.socket_client.setsockopt( + socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self.socket_client.bind(source_address) + # Timer self.fps = fps self.__clock = None