tags:

views:

31

answers:

2

I'm trying to port an ipv4 server/client to ipv6, but the compiler says SOCKADDR_IN6 is not declared in the scope. SOCKADDR_IN is declared but not SOCKADDR_IN6. <Winsock2.h> is included.

Any one have any ideas why it would be undeclared?

A: 

From msdn:

struct in_addr6 {
    u_char    s6_addr[16];             /* IPv6 address */
};

struct sockaddr_in6 {
    short             sin6_family;     /* AF_INET6 */
    u_short           sin6_port;       /* Transport level port number */
    u_long            sin6_flowinfo;   /* IPv6 flow information */
    struct in_addr6   sin6_addr;       /* IPv6 address */
    u_long            sin6_scope_id;   /* set of interfaces for a scope */
   };  

From your question i see that:

SOCKADDR_IN6 != sockaddr_in6

Lowercase vs. Uppercase confusion?
You may also not have the latest version of winsock, i'm not sure how far back support for IPV6 was introduced, you may want to check if thats your problem.

James
I have the latest version of MinGW which should have the latest version of Winsock. I also tried using sockaddr_in6 as lowercase, but it wasn't declared either. Where would I go to download the latest version?
Brad
I'd say that you're looking for this: http://msdn.microsoft.com/en-us/windows/bb980924.aspx
Tomaka17
+1  A: 

Microsoft's documentation for sockaddr_in6 says that it is defined in the ws2tcpip.h header, probably you need to include that.

On Linux you'd need different includes, sys/socket.h and netinet/in.h.

sth
Sorry, I'm using Windows. When I said " is included" I meant to say Winsock2.h is included. I put "<" and ">" tags around it so it must have been edited out for somereason
Brad
@Brad: Ah, I should have noticed the `winsock` tag... I edited my answer for Windows and also fixed the formatting of the `<winsock2.h>` in your question.
sth
thanks that seemed to fix the problem, although now I'm still getting getaddrinfo() isn't declared..
Brad