I created a tcp client in c++ and am using it in a blueprint. I call the receive function periodically with “set timer by function” block at 0.5 seconds. The receive function has a timeout of 1 ms, so it won’t block for long.
I am able to receive messages and act on them, but the rest of the program halts and is unresponsive while it is receiving messages. If I close the socket then the rest of the program runs ok.
How can I run a function in the blueprint periodically without blocking the rest of the program while it is waiting?
I think TCP by definition is a blocking process but maybe you could run it in a new thread to keep it from blocking the rest of your executable.
The TCP receive is only blocking for 1 ms. The set timer by function that is being used to trigger the receive twice a second is blocking the game thread… is there a non-blocking wait function?
So it’s not the TCP blocking that’s making a noticeable delay in your game, it’s the Timer function, or the part that sets the timer.
Can you show your code/blueprint for that part? Maybe we can figure it out by looking that over.