If you have ONE client and ONE server machine then you don't want to
have FIVE TCP connections.
1... Design a data structure. It should hold your five values, plus a
timestamp, or whatever else you want. Make it a TypeDef, for ease of
changes, if you want.
On the server (where the data comes from):
2... I would have a single loop to collect your data and put it into
this data structure, at whatever rate you need. This loop runs
regardless of whether there is a TCP connection or not. It also sets a
flag called NEW DATA.
3... Conn ID = invalid CONN ID (Initialize a shift reg) on 2nd WHILE
loop
3... Repeat
4... If shift reg is not VALID conn ID:
Wait for connection - assign conn ID
else
if NEW DATA flag NOT set
wait 20 mSec (or something)
else
Flatten latest data cluster into string.
Clear the NEW DATA flag.
Write string to connection.
5... until done.
On the client, you:
1... Open a connection.
2... S = flatten your Data Cluster into a string.
3... N = size of (S). Do not hardwire this constant, let it be
figured for you.
4... Repeat
5... Read N bytes from connection.
6... Unflatten string into your data type.
7... Display, store, whatever.
8... until done.
9... Close connection.
You'll have to add error checking, what to do if the connection
breaks, etc.
But that's the idea.