[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(usagi-users 02108) Re: multiproto bind() ?



In article <20030119015348.W43691-100000@xxxxxxxxxxxxxxxxxxxx> (at Sun, 19 Jan 2003 01:59:46 -0600 (CST)), Abdul Basit <basit@xxxxxxxx> says:

>          slen  = res->ai_addrlen;
>          ptr  = malloc(sizeof(int));
>          *ptr = accept(listenfd, caddr, &slen);
> 
>        // using res->ai_family 'd give same result.
>          printf("%uc\n",caddr->sa_family);
                     ~garbage?
>        }
> 
> i want to distinguish between clients coming to ipv4 or ipv6
> and print client address ? if i would get sa_family correct
> i can switch(family) { and case for AF_INET and AF_INET6 and
> use inet_ntop to print address ? but i am getting same family
> always (28c/bsd and 10c/linux --> AF_INET6)

please use getnameinfo().

--yoshfuji