Skip to content

Commit

Permalink
The unexpected behavior from #425 goes back to 258cddc which fixed ip…
Browse files Browse the repository at this point in the history
…v6 support by introducing getaddrinfo; one consequence of using getaddrinfo is that the address for hostname relies on the underlying C-API. A hostname of "" throws an error on linux but not on windows. Hence, the default value of hostname was change to None resulting in the default address becoming localhost. By adding the AI_PASSIVE flag, a hostname of None will result in a wildcard address (INADDR_ANY for IPv4 addresses, IN6ADDR_ANY_INIT) is used by applications to listen on all interfaces.
  • Loading branch information
comrumino committed Dec 26, 2020
1 parent 165ffe9 commit de0c515
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rpyc/utils/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class Server(object):
"""Base server implementation
:param service: the :class:`~rpyc.core.service.Service` to expose
:param hostname: the host to bind to. Default is IPADDR_ANY, but you may
want to restrict it only to ``localhost`` in some setups
:param hostname: the host to bind to. By default, the 'wildcard address' is used to listen on all interfaces.
if not properly secured, the server can receive traffic from unintended or even malicious sources.
:param ipv6: whether to create an IPv6 or IPv4 socket. The default is IPv4
:param port: the TCP port to bind to
:param backlog: the socket's backlog (passed to ``listen()``)
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(self, service, hostname=None, ipv6=False, port=0,
else:
family = socket.AF_INET
self.listener = socket.socket(family, socket.SOCK_STREAM)
address = socket.getaddrinfo(hostname, port, family=family, type=socket.SOCK_STREAM, proto=socket.IPPROTO_TCP)[0][-1]
address = socket.getaddrinfo(hostname, port, family=family, type=socket.SOCK_STREAM, proto=socket.IPPROTO_TCP, flags=socket.AI_PASSIVE)[0][-1]

if reuse_addr and sys.platform != "win32":
# warning: reuseaddr is not what you'd expect on windows!
Expand Down

0 comments on commit de0c515

Please sign in to comment.