Issue618594
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-10-04 15:08 by jcea, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (6) | |||
---|---|---|---|
msg12583 - (view) | Author: Jesús Cea Avión (jcea) * | Date: 2002-10-04 15:08 | |
You can connect to a IPv4 addr "a.b.c.d" from a IPv6 socket simply connecting to "::FFFF:a.b.c.d" IPv6 address. When you issue a "connect" call on a IPv6 socket using a pure IPv4 addr "a.b.c.d", this format SHOULD be converted "automagically" to "::FFFF:a.b.c.d", intenally. Currently, this operation gives an error. The real problem is "connect" call using a hostname (not resolved to a IPv4 or IPv6 addr). Since I don't know to which IP address type the host will resolve, I think the correct course should be to promote IPv4 to IPv6 address space (if the socket is IPv6) and to connect normally. Obviously, trying to connect to a IPv6 addr using a IPv4 socket should fail, like just now. When a hostname used in "connect" call resolves to both IPv4 and IPv6 addresses, it would use IPv4 if the socket is IPv4, and IPv6 if the socket is IPv6. |
|||
msg12584 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-10-05 10:11 | |
Logged In: YES user_id=21627 I fail to see a Python bug here. All calls are delegated to the C library, which delegates most of it to the kernel. So complain to your operating system vendor. I don't think your complaint is valid, though: the sockaddr is computed by looking at its format. If it does not contains a colon, it is not an AF_INET6. |
|||
msg12585 - (view) | Author: Jesús Cea Avión (jcea) * | Date: 2002-10-07 06:39 | |
Logged In: YES user_id=97460 The problem, as I said, is when you use a hostname in the "connect" call. Since the program has no control over the address type the DNS lookup will resolve, I, in my soft, can't search for colons in order to create IF_INET or IF_INET6 sockets, since that info is processed inside the "connect" call. |
|||
msg12586 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-10-07 06:46 | |
Logged In: YES user_id=21627 Can you please post an example connect call? Did you consider the IPv6 example in http://www.python.org/doc/current/lib/socket-example.html ? |
|||
msg12587 - (view) | Author: Jesús Cea Avión (jcea) * | Date: 2002-10-07 08:09 | |
Logged In: YES user_id=97460 >>> import socket >>> a=socket.socket(socket.AF_INET6,socket.SOCK_STREAM) >>> a.connect(("www.elmundo.es",80)) If "www.elmundo.es" is a IPv4 ONLY server, the connect "fails". Nevertheless, you can reach IPv4 hosts from IPv6 sockets, using the "::FFFF:a.b.c.d" format... You suggest using "getaddinfo". That could be an option but, then, this problem should be documented in docs, I think :-p |
|||
msg12588 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-10-07 11:02 | |
Logged In: YES user_id=21627 Please understand that we expose the functionality from the C library. If you do socket.getaddrinfo("www.elmundo.es",None,0,socket.SOCK_STREAM) you get [(2, 1, 6, '', ('193.110.128.200', 0))] i.e. there is *no* IPv4 mapped address reported from the C library. See http://www.wcug.wwu.edu/lists/netdev/199702/msg00179.html why there is no need to report one, and http://lwn.net/Articles/8646/ why IPv4 mapped addresses are considered harmful. See the examples of how to use getaddrinfo to solve this problem: getaddrinfo tells you to open a IPv4 socket if there is no IPv6 connectivity to the requested service. I see no need to change any documentation. If you think something should change, please submit a patch. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:43 | admin | set | github: 37261 |
2002-10-04 15:08:53 | jcea | create |