cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: NI_WITHSCOPEID (was Re: Debugging test cases) (fwd)

From: Joe Halpin <j.p.h_at_comcast.net>
Date: Mon, 29 Mar 2004 09:24:22 -0600

Daniel Stenberg wrote:

I added a call to gai_strerror() after getnameinfo() to see what's going
on a little better:

#include <sys/socket.h>
#include <netdb.h>

int main()
{
#ifdef NI_WITHSCOPEID
   struct sockaddr ss;
   int sslen;
   int rc;
   char hbuf[NI_MAXHOST];
   int fd = socket(AF_INET, SOCK_STREAM, 0);
   if(fd < 0)
     return 4;

   rc = getsockname(fd, (struct sockaddr *)&ss, &sslen);
   if(rc)
     return 1;

   rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf),
                      NULL, 0,
                      NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID);
   printf("rc = %s\n", gai_strerror(rc));

   if(rc)
     return 2;

   return 0; /* all is fine, use NI_WITHSCOPEID */
#else
   return 3; /* don't use NI_WITHSCOPEID, we don't have it! */
#endif
}

On Solaris 9 I get "rc = invalid ai_flags".

On Solaris 8 (SPARC) I get no output, but a return code of 3. This is a
fairly old version that's missing a lot of patches though.

Joe
Received on 2004-03-29