diff options
author | James Socol <me@jamessocol.com> | 2014-10-01 09:16:23 -0400 |
---|---|---|
committer | James Socol <me@jamessocol.com> | 2014-10-01 09:16:31 -0400 |
commit | c5d7875896656a889394aff23e152324348da952 (patch) | |
tree | aee6de63ed7b35c16bd8091590192651a3902470 | |
parent | 502946811d0b3520599edff477c4fdf0afc79286 (diff) | |
parent | dd7ce9169947e2a370a537700da2c4fae326204f (diff) | |
download | pystatsd-c5d7875896656a889394aff23e152324348da952.tar.gz |
Merge branch 'pull-52'
Fix #52.
-rw-r--r-- | statsd/client.py | 7 | ||||
-rw-r--r-- | statsd/tests.py | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/statsd/client.py b/statsd/client.py index ecad262..8bca7f2 100644 --- a/statsd/client.py +++ b/statsd/client.py @@ -69,8 +69,11 @@ class StatsClient(object): def __init__(self, host='localhost', port=8125, prefix=None, maxudpsize=512): """Create a new client.""" - self._addr = (socket.gethostbyname(host), port) - self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + family, _, _, _, addr = socket.getaddrinfo( + host, port, 0, socket.SOCK_DGRAM + )[0] + self._addr = addr + self._sock = socket.socket(family, socket.SOCK_DGRAM) self._prefix = prefix self._maxudpsize = maxudpsize diff --git a/statsd/tests.py b/statsd/tests.py index 751815c..41f487c 100644 --- a/statsd/tests.py +++ b/statsd/tests.py @@ -497,3 +497,7 @@ def test_socket_error(): sc._sock.sendto.side_effect = socket.timeout() sc.incr('foo') _sock_check(sc, 1, 'foo:1|c') + + +def test_ipv6_host(): + StatsClient('::1') |