Skip to content

Conversation

@dhoomakethu
Copy link
Contributor

Allows reusing the address when running pymodbus synchronous server. A new keyword arg is introduced allow_reuse_address (set to false by default to be backward compatible) to control this feature.

class ModbusTcpServer(socketserver.ThreadingTCPServer):
    """
    A modbus threaded tcp socket server

    We inherit and overload the socket server so that we
    can control the client threads as well as have a single
    server context instance.
    """

    def __init__(self, context, framer=None, identity=None,
                 address=None, handler=None, allow_reuse_address=False,
                 **kwargs):
        """ Overloaded initializer for the socket server

        If the identify structure is not passed in, the ModbusControlBlock
        uses its own empty structure.

        :param context: The ModbusServerContext datastore
        :param framer: The framer strategy to use
        :param identity: An optional identify structure
        :param address: An optional (interface, port) to bind to.
        :param handler: A handler for each client session; default is
                        ModbusConnectedRequestHandler
        :param allow_reuse_address: Whether the server will allow the
                        reuse of an address.
        :param ignore_missing_slaves: True to not send errors on a request
                                        to a missing slave
        """

@dhoomakethu dhoomakethu mentioned this pull request Sep 7, 2018
12 tasks
@dhoomakethu dhoomakethu merged commit 30703dd into dev Sep 7, 2018
@dhoomakethu dhoomakethu deleted the #322-Reuse-Address branch September 7, 2018 04:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants