Host.py 470 B

1234567891011121314151617181920
  1. import socket
  2. import chutney.Util
  3. @chutney.Util.memoized
  4. def is_ipv6_supported():
  5. """Return true iff ipv6 is supported on this host."""
  6. try:
  7. s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  8. s.bind(("::1", 0))
  9. s.listen(128)
  10. a = s.getsockname()
  11. s2 = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  12. s2.settimeout(1)
  13. s2.connect(a)
  14. return True
  15. except socket.error:
  16. return False