Skip to content

Commit

Permalink
use transport_listen tcp.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Jun 23, 2023
1 parent d98bf7c commit 3ecbcfb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,15 @@ def __init__(
:param response_manipulator: Callback method for manipulating the
response
"""
if not address:
address = ("", 502)
params = kwargs.get(
"internal_tls_setup",
CommParams(
comm_type=CommType.TCP,
comm_name="server_listener",
host=address[0],
port=address[1],
reconnect_delay=0.0,
reconnect_delay_max=0.0,
timeout_connect=0.0,
Expand All @@ -340,7 +344,7 @@ def __init__(
self.framer = framer or ModbusSocketFramer
self.context = context or ModbusServerContext()
self.control = ModbusControlBlock()
self.address = address or ("", 502)
self.address = address
self.ignore_missing_slaves = kwargs.get("ignore_missing_slaves", False)
self.broadcast_enable = kwargs.get("broadcast_enable", False)
self.response_manipulator = kwargs.get("response_manipulator", None)
Expand All @@ -362,6 +366,12 @@ def __init__(
self.factory_parms["ssl"] = params.sslctx
self.handle_local_echo = False

def handle_new_connection(self):
"""Handle incoming connect."""
handler = ModbusServerRequestHandler
handler.server = self
return handler

async def serve_forever(self):
"""Start endless loop."""
if self.server is None:
Expand Down

0 comments on commit 3ecbcfb

Please sign in to comment.