1
0
mirror of https://github.com/JoelBender/modpypes synced 2025-10-26 21:49:19 +08:00

allow a host parameter as well as a port parameter for listening on specific address

This commit is contained in:
Joel Bender 2017-03-28 12:54:21 -04:00
parent 09575f3f37
commit 2b136ee088

View File

@ -150,13 +150,13 @@ class ModbusClient(Client, Server):
@bacpypes_debugging @bacpypes_debugging
class ModbusServer(Client, Server): class ModbusServer(Client, Server):
def __init__(self, port=502, **kwargs): def __init__(self, host='', port=502, **kwargs):
if _debug: ModbusServer._debug("__init__ port=%r %r", port, kwargs) if _debug: ModbusServer._debug("__init__ host=%r port=%r %r", host, port, kwargs)
Client.__init__(self) Client.__init__(self)
Server.__init__(self) Server.__init__(self)
# create and bind # create and bind
self.serverDirector = TCPServerDirector(('', port), **kwargs) self.serverDirector = TCPServerDirector((host, port), **kwargs)
bind(self, StreamToPacket(stream_to_packet), self.serverDirector) bind(self, StreamToPacket(stream_to_packet), self.serverDirector)
def confirmation(self, pdu): def confirmation(self, pdu):