> I am just thinking about this particular scenario: I have made an IPv6
>compliant application (i.e. the socket is AF_INET6) that receives a URL
>to connect to the other side. Upon resolution of the DNS it finds the
>address is IPv4. Can this address be correctly routed to the IPv4 host
>and back. What code precaautions will I have to take?
use getaddrinfo.
itojun
char *dst;
char *port;
int s;
struct addrinfo hints, *res, *res0;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(dst, port, &hints, &res0);
if (error) {
fprintf(stderr, "%s\n", gai_strerror(error));
exit(1);
}
for (res = res0; res; res = res->ai_next) {
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (s < 0)
continue;
if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
close(s);
continue;
}
freeaddrinfo(res0);
/* do your stuff */
exit(0);
}
freeaddrinfo(res0);
fprintf(stderr, "connection failed\n");
exit(1);
---------------------------------------------------------------------
The IPv6 Users Mailing List
Unsubscribe by sending "unsubscribe users" to [EMAIL PROTECTED]