We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mostly bind does the right thing if you set AF_INET6 as the family type - maybe try that as a fallback?
diff --git a/pystatsd/server.py b/pystatsd/server.py index 40118c8..0bb9f9a 100644 --- a/pystatsd/server.py +++ b/pystatsd/server.py @@ -300,8 +300,23 @@ class Server(object): def serve(self, hostname='', port=8125): assert type(port) is int, 'port is not an integer: %s' % (port) addr = (hostname, port) - self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self._sock.bind(addr) + try: + self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + self._sock.bind(addr) + except socket.gaierror as e: + if e.errno not in ( + # Address family for hostname not supported + socket.EAI_ADDRFAMILY, + # Name or service not known + socket.EAI_NONAME): + raise + # IPv6 address calls for (host, port, flowinfo, scopeid) + # although, flowinfo and scopeid would default to 0 in + # socketmodule.c we're explict here + flowinfo = scopeid = 0 + addr = (hostname, port, flowinfo, scopeid) + self._sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) + self._sock.bind(addr) import signal
The text was updated successfully, but these errors were encountered:
No branches or pull requests
mostly bind does the right thing if you set AF_INET6 as the family type - maybe try that as a fallback?
The text was updated successfully, but these errors were encountered: