Download

FUdpSocketReceiver() thread timeout does what?

I found this sample code for receiving data via a UDP socket. I’m not clear what the ThreadWaitTime does.

FTimespan ThreadWaitTime = FTimespan::FromMilliseconds(100);
UDPReceiver = new FUdpSocketReceiver(UDPSocket, ThreadWaitTime, TEXT(“UDP Query Socket”));
UDPReceiver->OnDataReceived().BindUObject(this, &AUDPSQuery::Recv);

After some experimentation and a quick look at the engine code, the parameter seems to do nothing. The docs don’t provide any info on this. Anyone know what this does (if anything)?

I’m completely guessing here - but I suspect that the Socket Receiver is created on another thread since it needs to wait for an asyncronous event (i.e, while it’s waiting for info it shouldn’t “block” gameplay etc.) - so perhaps ThreadWaitTime is how long it should wait before it stops doing anything?

Again… total guess. May give you a hint though.

On the surface, that’s what it sounds like it should do. However, in practice the thread never times out. I’ve set the timeout to 100mS and sent data to it minutes later and it still responds. As it turns out I don’t want the receiver thread to ever time out. So this is working just fine for my situation. But it would be nice to know if this is a bug with the timeout or by design. I don’t want a future update to break my code.