On Tue, 15 Jan 2002, Hrvoje Niksic wrote:

> > I'd suggest that you instead pass around a 'struct hostent *' on
> > IPv4 only platforms
>
> Why?  The rest of the code never needs anything from `struct hostent'
> except the list of addresses, and this is what my code extracts.

Well, why extract the addresses when you can just leave them in the struct
and pass a pointer to that?

I am only suggesting this as it makes things a lot easier. There's not much
overhead in keeping the hostent compared to keeping the addresses only.

> > IPv6 addresses are scoped, but that is nothing you have to care
> > about as mere application writer (unless you really want to of
> > course). If you just keep the list of addresses in the addrinfo
> > struct and you try all them when you connect, then it'll work
> > transparantly.
>
> `struct addrinfo' contains a `struct sockaddr', which carries the necessary
> scoping information (I think).  The question at the time was whether I
> could extract only the "address(es)" and ignore everything else, as it was
> possible with IPv4.  Itojune implied that "scoping" of addresses made this
> hard or impossible.

Right, you can't just extract a few things from that struct and go with them
without very careful considerations. Hence my suggestion to go with the
'addrinfo' struct as container for information for a particular host for IPv6
machines.

connect()ing on machines that support getaddrinfo() should be a matter of
running through the addrinfo-list and perform something in this style:

      struct addrinfo *ai;

      sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
      rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen);

Which then implies that you need the full addrinfo struct for this...

Anyway, I'm only suggesting based on my limited IPv6-experiences (making curl
fully IPv6 compliant), I'll of course respect whatever decision you make on
this.

-- 
      Daniel Stenberg - http://daniel.haxx.se - +46-705-44 31 77
   ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol

Reply via email to