On Linux we have a problem stopping an InterprocessConnectionServer cleanly. The problem is that it will internally create a Socket and call waitForNextConnection(), which will hang indefinitely if there is no incoming connection.
When stopping the server, it tries to unblock this call by creating a connection (juce_Socket.cpp line 380), but fails. I investigated this a bit but couln't find the problem. I know that in juce_Socket.cpp on line 176 the getsockopt() call returns ECONNREFUSED.
It worked correctly before we upgraded to JUCE 3. Any thoughts on what could be the issue?
There's nothing special about reproducing this issue. So probably this is system dependent:
class TestServer : public InterprocessConnectionServer
{
virtual InterprocessConnection* createConnectionObject() { return nullptr; }
};
{
TestServer s;
s.beginWaitingForSocket(54321);
}
I did some testing and found out that it's only possible to connect to the socket using IPv4 localhost address (127.0.0.1) and not when using the IPv6 link-local address (::1).
I ran Wireshark, and it turns out the temporary connection is going to ::1, so it fails.
A temporary fix is to replace "localhost" with "127.0.0.1" on line 386 in juce_Socket.cpp. Making sure IPv6 works is a bit involved, as described here: http://uw714doc.sco.com/en/SDK_netapi/sockC.PortIPv4appIPv6.html.