Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sockaddr_in6 not declared?

Tags:

c++

ipv6

winsock

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?

like image 490
Brad Avatar asked Dec 16 '22 22:12

Brad


2 Answers

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.

like image 124
sth Avatar answered Dec 19 '22 13:12

sth


I have currently found SOCKADDR_IN6 definition in ws2ipdef.h header (Visual Studio 2008). However, as said in a comment below, MS Docs states that this header should never be used directly (use Ws2tcpip.h instead).

like image 29
Alexandre Avatar answered Dec 19 '22 13:12

Alexandre