StreamingSocket server not detecting when client closes connection?

Hi there!

I’m new to JUCE Framework development.
I really like the framework and I already implemented my first VST3 Plugin…

I do have a question about StreamingSocket and how to detect that client has closed the connection.
I look like, the isConnected() Method only returns false, when the server itself closes the connection, but not when the client closes it.

Can someone help me understanding why my StreamingSocket server is still sending messages even when the client closes the connection?
Is the StreamingSocket not interpreting FIN command (BUG) or do i have to change my code?


void run() override
    DBG("Thread running...");

    juce::StreamingSocket* socket = new juce::StreamingSocket();
    juce::StreamingSocket* connection = nullptr;
    juce::String loudness = juce::String(shortTermLoudness_);

    DBG("Creating listener on: " + localHostName_ + " port: " + String(portNumber_));
    bool listening = socket->createListener(portNumber_, localHostName_);
    char buffer[MAX_URL_SIZE];

    if (listening)
        DBG("Listening to: " + localHostName_ + " port: " + String(portNumber_));
        printf("Listening to ip: ip\n");

        while (!threadShouldExit())
            DBG("Waiting for connection");
            connection = socket->waitForNextConnection();
            DBG("Client connected");
            while (
                && connection != nullptr
                && connection->isConnected()
            ) {
                if (connection != nullptr) {
                    string res = getResponse();
                    const char* response = res.c_str();
                    DBG("Sending values " + res);
                    connection->write(response, strlen(loud_response));
                    sleep(2000); // avoid burning CPU
            DBG("Connection closed or thread should exit.");
        DBG("Thread exit");
        if (connection != nullptr && connection->isConnected()) {
    else {
        DBG("Conection Error \n");
        printf("Conection Error \n");