LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP callback in own thread

Hi!
 
I´m writing a server/client application. In the server I want that the callback for TCP events will be processed in a own thread that the whole server will not be blocked during TCP communication. How can I do this?
My idea is that I create a thread and in this thread I register the server with "RegisterTCPServer (Port, TCPCallback, 0)". But now I don´t know if the callback "TCPCallback" will be processed within this thread or not.
 
Can anybody help me pls?
 
Thx
Thomas
0 Kudos
Message 1 of 4
(3,449 Views)
Thomas,
 
Yes, events are sent to the thread in which you registered the server. One thing to keep in mind is that this thread needs to be processing events. So after registering the server, your thread function needs to be doing something like:
 
    while (!done)
        ProcessSystemEvents();
 
Luis
NI
0 Kudos
Message 2 of 4
(3,440 Views)
Hi!
 I am making a multithreading application. And I'd like to know if it's the same mechanism for Data Socket.
 If I use DS_OpenEx () in a thread ,will the "void CVICALLBACK DSCallback " will be run in this thread??

 Thanks for Help

Paul
0 Kudos
Message 3 of 4
(3,280 Views)
Yes, the mechanism is similar in DataSocket and your callback will be called in the thread that called DS_Open or DS_OpenEx, and this thread should process events.
0 Kudos
Message 4 of 4
(3,265 Views)