# Registry

RPyC registry server implementation. The registry is much like Avahi or Bonjour, but tailored to the needs of RPyC. Also, neither of them supports (or supported) Windows, and Bonjour has a restrictive license. Moreover, they are too “powerful” for what RPyC needed and required too complex a setup.

If anyone wants to implement the RPyC registry using Avahi, Bonjour, or any other zeroconf implementation – I’ll be happy to include them.

Refer to `rpyc/scripts/rpyc_registry.py` for more info.

class `rpyc.utils.registry.``RegistryServer`(listenersock, pruning_timeout=None, logger=None)

  Base registry server

  `on_service_added`(name, addrinfo)

    called when a new service joins the registry (but not on keepalives). override this to add custom logic

  `on_service_removed`(name, addrinfo)

    called when a service unregisters or is pruned. override this to add custom logic

  `cmd_query`(host, name)

    implementation of the `query` command

  `cmd_register`(host, names, port)

    implementation of the `register` command

  `cmd_unregister`(host, port)

    implementation of the `unregister` command

  `start`()

    Starts the registry server (blocks)

  `close`()

    Closes (terminates) the registry server

class `rpyc.utils.registry.``UDPRegistryServer`(host='0.0.0.0', port=18811, pruning_timeout=None, logger=None)

  UDP-based registry server. The server listens to UDP broadcasts and answers them. Useful in local networks, were broadcasts are allowed

class `rpyc.utils.registry.``TCPRegistryServer`(host='0.0.0.0', port=18811, pruning_timeout=None, logger=None, reuse_addr=True)

  TCP-based registry server. The server listens to a certain TCP port and answers requests. Useful when you need to cross routers in the network, since they block UDP broadcasts

class `rpyc.utils.registry.``RegistryClient`(ip, port, timeout, logger=None)

  Base registry client. Also known as registrar

  `discover`(name)

    Sends a query for the specified service name.

    Parameters: | name – the service name (or one of its aliases)
    Returns: | a list of `(host, port)` tuples

  `register`(aliases, port)

    Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

    Parameters:

    - aliases – the `service's` aliases
    - port – the listening TCP port of the server

  `unregister`(port)

    Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

    Parameters: | port – the listening TCP port of the RPyC server to unregister

class `rpyc.utils.registry.``UDPRegistryClient`(ip='255.255.255.255', port=18811, timeout=2, bcast=None, logger=None, ipv6=False)

  UDP-based registry clients. By default, it sends UDP broadcasts (requires special user privileges on certain OS’s) and collects the replies. You can also specify the IP address to send to.

  Example:

      registrar = UDPRegistryClient()
      list_of_servers = registrar.discover("foo")

  Note

  Consider using `rpyc.utils.factory.discover()` instead

class `rpyc.utils.registry.``TCPRegistryClient`(ip, port=18811, timeout=2, logger=None)

  TCP-based registry client. You must specify the host (registry server) to connect to.

  Example:

      registrar = TCPRegistryClient("localhost")
      list_of_servers = registrar.discover("foo")

  Note

  Consider using `rpyc.utils.factory.discover()` instead