Does connectToSocket() cause lag on Windows 10?


I have plugin which use connectToSocket(). And if I have situation when there is nothing to connect it just returns false. And it works great on Mac (AudioUnit), but on Windows 10 (VST3) it causes lag (big lag, my plugin and host is unable to use, I can’t even click anything). But when there is any other plugin with beginWaitingForSocket() turned on, then everything works OK. (but on Windows I need to provide it before I run my plugin with connectToSocket(), because in other case as I told it blocks whole host).

Why is that?

But please let me explain other thing: I am not sure if I use connectToSocket() properly.
According to documentation beginWaitingForSocket() starts internal thread which listens on the given port number. But for connectToSocket() there is no info about any “internal thread”, so I suppose it tries just ones, but it waits timeOutMillisecs, and after that time it just returns bool, and if it’s false it will not try to connect again.

But I want my plugin always try to connect until connection is successful. But I can’t find any info such like “if you set timeOutMillisecs = 0 then it will try to connect endless”, or anything like that. So I am not sure how to provide my desired behaviour “always try to connect”.

So I put connectToSocket() in the timerCallback(). And when connection is successful I stopTimer(). And on that point on Mac it works as I expect, but on Windows 10 it cause endless lag. How to avoid that.

I think maybe I should create independent Thread to make connection. Because now my InterprocessConnection is my main window class AudioProcessorEditor. Maybe it causes the problem? But I am not sure, and I don’t have possibility to test it (due to fact I have Windows only on my computer in job, where I can only test later, but I can’t program my plugins during job :slight_smile: )

PS. Other think that probably should be mentioned. I set connectToSocket(myHostName, myPortNumber, 1000). So it should wait on connection 1000 milliseconds. And when I debug it, when I have breakpoint on line with connectToSocket(), and when I hit “Step over”, it looks like there is different behaviour on Mac and on Windows. On Mac when I click “Step over” it jumps immediately to next line, but on Windows it waits 1 seconds, and then it jump to next line. So it looks like on Windows it works properly, and on Mac it doesn’t wait timeOutMillisecs. But unfortunately on Mac my plugin doesn’t crash but on Windows it does. Strange things, I can’t understand that. Please help me.


OK, I think now I figure it out why is that. My timer is set to startTimer(1000).

So it’s the same time as in connectToSocket(myHostName, myPortNumber, 1000). But as I explained I can’t test it now. So could anyone tell me if it’s really the solution to set for example startTimer(2000) (two times slower than connectToSocket() which is set in timerCallback())

But even though, then there is still question, why on Mac connectToSocket(myHostName, myPortNumber, 1000) doesn’t wait 1000 millisecond?