# Closing an juce::InterprocessConnectionServer

**URL:** https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227
**Category:** Linux
**Created:** [July 23, 2014, 3:42am UTC](https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227 "2014-07-23T03:42:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![roeland-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/roeland-2/32/738_2.png) [@roeland-2](https://forum.juce.com/u/roeland-2)
#### Post date: [July 23, 2014, 3:42am UTC](https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227/1 "2014-07-23T03:42:23Z")

</div>

Hi,

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?

--  
Roeland

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)
#### Post date: [July 23, 2014, 9:25am UTC](https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227/2 "2014-07-23T09:25:49Z")

</div>

That's odd - linux should work the same as OSX where I've tested that stuff quite heavily.

Do you have a snippet of test code that I could use to reproduce it?

---

<div class="post-metadata">

### Author: ![roeland-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/roeland-2/32/738_2.png) [@roeland-2](https://forum.juce.com/u/roeland-2)
#### Post date: [July 24, 2014, 12:09am UTC](https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227/3 "2014-07-24T00:09:39Z")

</div>

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.

--  
Roeland

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)
#### Post date: [July 24, 2014, 11:31am UTC](https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227/4 "2014-07-24T11:31:19Z")

</div>

Perhaps a good fix for that line in Socket would be:

```
temp.connect (IPAddress::local().toString(), portNumber, 1000);
```

(I guess the IPAddress class will have to be changed to deal with IPv6 eventually anyway)

---

<div class="post-metadata">

### Author: ![roeland-2](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/roeland-2/32/738_2.png) [@roeland-2](https://forum.juce.com/u/roeland-2)
#### Post date: [July 25, 2014, 1:46am UTC](https://forum.juce.com/t/closing-an-juce-interprocessconnectionserver/13227/5 "2014-07-25T01:46:50Z")

</div>

I can confirm it works after updating JUCE, thanks.

--  
Roeland
