Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89720
| From | Alain Ketterlin <alain@dpt-info.u-strasbg.fr> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Am I missing something here? ipaddress vs socket |
| Date | 2015-05-01 12:31 +0200 |
| Organization | Universites Paris VI/Paris VII - France |
| Message-ID | <87r3r07foa.fsf@dpt-info.u-strasbg.fr> (permalink) |
| References | <f46cdd6e-5c94-4370-a368-cce0bd68c997@googlegroups.com> |
the.loeki@gmail.com writes: > Given the following code: > > import ipaddress > import socket > > ip = ipaddress.ip_address(mystring) > sock_family = ip.???? > socket = socket.socket(sock_family, socket.SOCK_STREAM) > > Am I crazy or is this undoable? > > sock.AF_INET == 2 > sock.AF_INET6 == 10 > ip.version == 4 or 6 Check the value of the "version" attribute. Or use socket.getaddrinfo(), which is more convenient if all you need is an address parser. -- Alain.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Am I missing something here? ipaddress vs socket the.loeki@gmail.com - 2015-05-01 02:42 -0700
Re: Am I missing something here? ipaddress vs socket Chris Angelico <rosuav@gmail.com> - 2015-05-01 20:11 +1000
Re: Am I missing something here? ipaddress vs socket Ronald van Zantvoort <the.loeki@gmail.com> - 2015-05-01 03:41 -0700
Re: Am I missing something here? ipaddress vs socket Chris Angelico <rosuav@gmail.com> - 2015-05-01 22:06 +1000
Re: Am I missing something here? ipaddress vs socket Ronald van Zantvoort <the.loeki@gmail.com> - 2015-05-01 06:37 -0700
Re: Am I missing something here? ipaddress vs socket Chris Angelico <rosuav@gmail.com> - 2015-05-01 23:46 +1000
Re: Am I missing something here? ipaddress vs socket Ronald van Zantvoort <the.loeki@gmail.com> - 2015-05-01 06:48 -0700
Re: Am I missing something here? ipaddress vs socket Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2015-05-01 12:31 +0200
csiph-web