StreamingSocket not connecting on OSX


#1

Hello,
i’m trying to use StreamingSocket on a cross platform app, on windows i can use the StreamingSocket to connect to a remote server and send messages, but on osx, the same code is doing absolutely nothing.
I can verify that on OSX the StreamingSocket is actually not even trying to connect because of the timeout.
I kept the connect function with a 3s timeout in the main thread so when the server is not reachable, the whole program freezes for 3s, that way i know that my app tried to connect and failed (just for testing).
But on OSX, even if the server is not running, my app doesn’t freeze at all and the connect function returns false immediately.

Any idea ?

my basic code :

if (sender.isConnected()) sender.close(); 
bool result = sender.connect(useLocal->boolValue() ? "127.0.0.1" : remoteHost->stringValue(), remotePort->intValue());
isConnected->setValue(result);

Thanks


#2

Run your code from the command line, look for errors from OSX in the console. Possibly you’re being blocked by some of the OSX network connections policies?


#3

Maybe this: https://forums.developer.apple.com/thread/6205

But I’m guessing :slight_smile:


#4

Thank you !
Actually i already had the settings right for that, because i also wanted to do OSC with my application and that same problem had already occured.
So i’ve got my info.plist allowing everything in and out, and in the console there is not much going on, sometimes i get “TCP connection cancel” but i doubt this comes from my app because i tried connecting to 1000 ports at the same time to flood the console and see obvious messages, but nothing happened. I suspect that JUCE is not trying to connect but i don’t know where.
Also, i’m on VMWare to test the app on OSX but i’ve got the same result from a friend that tested the app on a real mac.


#5

Ah and i forgot to mention, the remote server is on localhost, i’m actually trying to control VLC via TCP - (works on windows with the same code, got other problems but mentionned them on another topic)


#6

I just tried connecting to VLC on high sierra via a StreamingSocket and it works for me. If I have VLC open the connection succeeds immediately. If I close VLC the connection will fail. Have you tried connecting to VLC on your mac with another app - like telnet or your browser? Both also work for me.


#7

Sorry for the delay, i’ll try that. Also, is there a way to know if the TCP connection is still alive ?
On C#, there is a special message to send to check if the connection is still good without having to send a real message, it looks like this :

private void CheckStillConnected()
{
    try
    {
        if (_tcpClient.Client.Poll(0, SelectMode.SelectRead))
        {
            byte[] buff = new byte[1];
            if (_tcpClient.Client.Receive(buff, SocketFlags.Peek) == 0)
            {
                // Client disconnected
                isConnected = false;
            }
        }
    }catch(Exception e)
    {
        isConnected = false;
    }
}