Le jeudi, 24 avr 2003, à 17:13 Europe/Paris, Niels Möller a écrit :
Xavier Beaudouin kiwi@oav.net writes:
I am ok with the idea that Programming in Pike should be easier in Pike than in C. But if we look in DNS for ipv4/6 address and there is no DNS server responding, how can Pike should react ?
I don't quite understand this remark. If a pike program wants to look up an dns name (for instance by Stdio.File()->connect("pike.ida.liu.se", 22)), and the name can't be resolved, then connect has to fail in one way or the other. But that hasn't got much to do with IPv4/IPv6.
humm.. yeah you are right... but Stdio.File()->connect("127.0.0.1", 22); can pass by DNS...
Imagine such entry :
127.0.0.1.mydomain.com. IN A 10.12.1.4 IN AAAA 3ffe::dead
How can we sure that 127.0.0.1 is ipv4 not ipv6 ?
After reading some of the pike code (in particuler get_inet_addr, in system.c), it seems pike will only use one address. Then we're in trouble if there are two addresses, one ipv4 and one ipv6, and only one of them works. Here, an application preference could help a little. Or one could just hope or assume that the system resolver is smart enough, and for example returns the IPv4 address(es) first if we have no IPv6 connectivity. (I think there's some internet draft on address selection that the resolved is supposed to follow, and the sorting rules are quite hairy).
I agree.
I think the right way to solve this is to have some function that given a name returns a list of addresses (somewhat like getaddrinfo, but perhaps with a more pikish interface). The low level connect function should accept such an address list, and try all addresses. This can be completely transparent to pike programs using the connect method (and it can get pretty fancy with asyncronous connects, as pike can try to connect to a few addresses in parallel).
And there should be a listen function that takes a list of addresses and binds and listens on all of them. This seems a little harder to do transparently, though.
Yeah
Also, I think that we should explicitly provide if we want a IPv6 only or IPv4 or both v4/v6 addresses when open a socket.
One can have some option that says "I would prefer IPv6 for this socket" or "I *must* have IPv6 on this socket, if that doesn't work, the operation should fail rather than fall back to IPv4". But most programs should not need to care about that.
/Niels