I have a Labwindows server that listens for data from a python client on a remote machine. On the Labwindows server, whenever the TCP_DATAREADY event is fired, I read the buffer to get the data from the client. At this point I need to parse the data and update UI controls. However, since data arrives frequently, it is best if I can assign the task of parsing the data and updating UI controls to a different thread, so the server won't lose any data from the client.
I have thought of using thread safe queues in Labwindows. However, the data I get from the client is a string. How do I construct a queue which has string elements? I can't use pointers as the data received from the client is updated everytime data arrives.
Here is the piece of code that reads data from the socket:
case TCP_DATAREADY:
if ((dataSize = ServerTCPRead (g_hconversation, receiveBuf,
dataSize, 1000))
< 0)
{
SetCtrlVal(g_hconversation, MAINPNL_TEXTBOX,"Receive Error");
}
else
{
//receiveBuff should be passed to function that decides where to display it
display_value_from_client(receiveBuf);
}
So, receiveBuf is constantly changing and saving pointers to it in the queue won't help. How do I implement threading here so my threads take care of the parsing functionality and I only need to worry about reading data from the socket in the main thread?