StreamingSocket::connect to ipv6?

Hi, I’m converting my app to work with IPv6 addresses but I notice the connection fails after a call to gethostbyname in connectSocket.

I’ve been looking at the documentation and it looks like this should really be changed to gethostbyaddr which supports ipv6.

Just wondering if anyone has experience in doing this or if there is already another accepted method of doing this in Juce before I go ahead and change the code?


I hadn’t realised that it needed changing… But looking at the docs, both of those functions are deprecated:

and it should be using getaddrinfo() instead… I guess I need to update that.

ah yes… I was looking at the MS documentation of gethostbyaddr which still shows it as valid.

Any chance you would make that change any time soon or shall I change it my end?

Already done and checked in.

Just downloaded the latest tip. Maybe I’m missing a setting but I don’t think Win7 VS2010 is liking this:

c:\users\gman\dev\git\juce\src\io\network\juce_socket.cpp(263): error C3861: ‘getaddrinfo’: identifier not found
c:\users\gman\dev\git\juce\src\io\network\juce_socket.cpp(271): error C3861: ‘freeaddrinfo’: identifier not found
c:\users\gman\dev\git\juce\src\io\network\juce_socket.cpp(281): error C3861: ‘freeaddrinfo’: identifier not found
c:\users\gman\dev\git\juce\src\io\network\juce_socket.cpp(285): error C3861: ‘freeaddrinfo’: identifier not found
c:\users\gman\dev\git\juce\src\io\network\juce_socket.cpp(292): error C2446: ‘==’ : no conversion from ‘int’ to 'addrinfo *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
c:\users\gman\dev\git\juce\src\io\network\juce_socket.cpp(292): error C2040: ‘==’ : ‘addrinfo *’ differs in levels of indirection from 'int’

ah, I only tested mac + linux. Will have a go with windows…

was just about to post the same… needs the following (please correct if needed Jules).

  1. Add the following line in the includes (ws2tcpip.h)
  #include <winsock2.h>
  #include <ws2tcpip.h> (*** ADD THIS LINE)
  1. Change
if (result== SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)


if (errno == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK)

Yeah, sorted now, thanks.

having a few problems with this, the connect is returning true but when I try to use the socket it says its not connected.

I notice there is no ::connect call on the socket, isnt that needed?

I had accidentally removed it, but already put it back in my last check-in - didn’t you grab that?

Sorry was being a div and didnt update my version.

Quick fix though, you’re free’ing the info before the connect so the connect is going in with junk data.

Moving the freeaddrinfo to below the connect line works a treat and connection works fine.

The latest is not building for me. Still can’t find getaddrinfo or freeaddrinfo?

Doh… Sorry, I’ve got a stinking cold today, I’m clearly not functioning at 100% efficiency!

It’s building for me, though - I definitely added the win32 include file…

Hey no problem. I think you’re missing the include for ws2tcpip.h

Ah, I did add it to the native includes, but I guess that won’t work if you’re not using the amalgamated versions. Ta, I’ll add it to socket.cpp too.