ofxNetwork UDP between two apps on same machine shows significant delay -- why?

I’ve got two OF apps. #1 is a simple openCvHaarFinder, and #2 displays video clips. They are running on the same machine and connected via an ofxNetwork UDP socket.

When the openCv app detects a face, it sends a UDP message to #2 of “face”. When it doesn’t, it sends “noface”.

I have both apps printing which message it is sending or receiving. When I watch the output in real time, what I see is that the receiver app is well behind the sender app, say 2 seconds or so. In other words, if my sender sends:

face
face
face
noface
face
face

then it will take ~2 seconds before I see that same pattern appear on the receiver app.

I have the framerate set to 24 on both apps.

Any idea what’s going on? I built it directly from the UDPsender and receiver examples that come with oF.

thx

are you reading one message each frame? if so trying reading all messages in a loop till there’s nothing left if the buffer

Yes, I put the send in update() in the sender and the read in update() in the receiver. Is there a better place than update() to do this (whether a single read or a loop)? Maybe I need to launch a thread that just sits and listens for new messages from the sender?

it’s ok in update, just in the receiver do a while loop in the update till there’s no more messages

that fixed it, thanks so much.