I did a little experiment:
>>> import socket >>> s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) >>> s.bind(('::', 0)) >>> s.listen(50) >>> s.getsockname() ('::', 39025, 0, 0)
Okay, looks good.
$ lsof -i TCP:39026 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ipython 71207 gavin 5u IPv6 492194 0t0 TCP *:39025 (LISTEN)
It doesn't show IPv4 there, but as Mike says, this is a compatibility mode so I'm not entirely surprised.
Next, in another shell:
$ telnet localhost 39025 Trying 127.0.0.1... Connected to localhost. ...
At the same time:
>>> s.accept() (<socket._socketobject at 0x7fc88bc41c20>, ('::ffff:127.0.0.1', 35080, 0, 0))
Okay, so the server sees an IPv4 address mapped into the IPv6 address space.
Again, in another shell:
$ telnet ::1 39025 Trying ::1... Connected to ::1. ...
Again, at the same time:
>>> s.accept() (<socket._socketobject at 0x7fc88a87d0c0>, ('::1', 43349, 0, 0))
No surprises here.
« Back to merge proposal
I did a little experiment:
>>> import socket socket( socket. AF_INET6, socket.SOCK_STREAM)
>>> s = socket.
>>> s.bind(('::', 0))
>>> s.listen(50)
>>> s.getsockname()
('::', 39025, 0, 0)
Okay, looks good.
$ lsof -i TCP:39026
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ipython 71207 gavin 5u IPv6 492194 0t0 TCP *:39025 (LISTEN)
It doesn't show IPv4 there, but as Mike says, this is a compatibility
mode so I'm not entirely surprised.
Next, in another shell:
$ telnet localhost 39025
Trying 127.0.0.1...
Connected to localhost.
...
At the same time:
>>> s.accept() _socketobject at 0x7fc88bc41c20>, ('::ffff: 127.0.0. 1', 35080, 0, 0))
(<socket.
Okay, so the server sees an IPv4 address mapped into the IPv6 address
space.
Again, in another shell:
$ telnet ::1 39025
Trying ::1...
Connected to ::1.
...
Again, at the same time:
>>> s.accept() _socketobject at 0x7fc88a87d0c0>, ('::1', 43349, 0, 0))
(<socket.
No surprises here.