LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP callbacks

Hi all, we are trying to process incoming TCP data with a callback initiated in a .dll, and it works fine, until there is a Sleep or Delay function called in the main program. The callbacks seems to wait until the end of the delay/Sleep, and only run afterwards. Is there a function where we can enable/prioritize callbacks during delay calls? During the main program the timing is critical, so I would avoid calling ProcessTCPEvents in loop. 

 

Thanks in advance!

0 Kudos
Message 1 of 4
(4,210 Views)

Hello !

 

I was able to resolve the same type issue using the following function.

 

 

 

int Sleep(double dblDelay)  

 static double dblTime1;
 static double dblTime2;
 dblTime1 = Timer();
 dblTime2 = Timer();
 while ((dblTime2 - dblTime1) < dblDelay) 
 {  
  dblTime2 = Timer();
  ProcessSystemEvents();
 }
 return 0;
}

 

 

 

 

hope it helps you too !

 

 

0 Kudos
Message 2 of 4
(4,193 Views)

network events in the CVI TCP library are implemented using window messages, the same kind of events which signals mouse button clicks or such. thus, for the callback to be called, you must have a running message loop, either by way of RunUserInterface() or by calling ProcessSystemEvents() in a loop.

 

this specificity of the network library is documented in the help for RegisterTCPServer().

 

(eventually, NI will one day re-implement their TCP library using events instead of window messages. hint to NI: replace WSAAsyncSelect() by WSAEventSelect()...)

0 Kudos
Message 3 of 4
(4,153 Views)
Thanks Sirs, Norrod's solution is working temporarly, but then we are waiting for NI for the final solution.....
0 Kudos
Message 4 of 4
(4,126 Views)