Interprocess Socket communication - localhost not working


tested on Win7 & Win8

If i start two instances of JUCE-Demo, one as listener, another as sender on the same computer (with Socket Host “localhost”) , the connection couldn’t be established.

if these instances are on different computers it works (in both directions!, so i guess it has nothing to do with the internal windows firewall)

So, what JUCE demo says

does not work here.


okay, using instead does work!


This is still true, any ideas why "localhost" wouldn't work?

By the way, where did the IPC demo go? It's no longer in the JUCE Demo project.


I experienced the same issue with using the OSCSender class, which I assume has the same socket implementation underneath. Can’t send messages to “localhost”, but “” works fine. Any suggestions?


It looks to be because

    static addrinfo* getAddressInfo (const bool isDatagram, const String& hostName, int portNumber)

only takes numerical address, as indicated by this setting within it:

        hints.ai_flags = AI_NUMERICSERV;


My understanding is that this only relates to the “service”, i.e. port number. I’ve certainly used getAddressInfo with a hostName that isn’t an IP address and it worked fine.


I responded to your reply, but realized I misread it. So, to clarify, you’ve used the JUCE function getAddressInfo with a non-numerical host-name or you’ve done so with the low level getaddrinfo?

And, if that is the case, I recommend using a debugger to see where things are failing. Drop a breakpoint in getAddressInfo and see where things go wrong. And/or, for further testing verification, remove the hints.ai_flags = AI_NUMERICSERV; line and see if that makes a difference. I did see some references online that Windows tends to return ::1 for localhost, but I’m not sure how that would effect things.


Thanks for the reply. When I get I chance I’ll need to do some debugging of this. I was hoping that someone more expert than me in this area would just know :wink:

I’m running into the problem using the Juce OSC module. I happen to know that the getaddrinfo gets IPs from hostnames because I’ve used it elsewhere in my code.