06-11-2013 10:27 PM
I am writing two programs (server.vi) and (client.vi). that communicate with each other over a TCP connection.
After the client opens a TCP connection with the server, the server responds with a packet of type "A". The client sends another packet of type "A" back to the server as an acknowledgement. At this point the server starts sending a continous stream of packets of type "B" to the client. And the client starts sending a continous stream of packets with type "C".
This means the sending an receiving of packet with types B and C will be in parallel.
How should I implement something like this in labview?
Here is one idea i have and I was hoping someone could either comment or provide a better suggestion.
1. the server has two while loops
a. first while loop consists of a TCP read function that receives packets of type "C".
b. second while loop consists of a TCP write function that sends packets of type "B"
2. the client has two while loops
a. first while loop consists of a TCP write function that sends packets of type "C"
b. second while loop consists of a TCP read function that receives packets of type "B".
This way we are sending and receiving packets of type "B" and "C" in parallel.
Does this make any sense? Is there a more clever / better aproach to doing this?
06-11-2013 10:34 PM
The while loops are independent of each other and are essentially infinite until the while program is stopped.
06-12-2013 11:00 AM
Putting the sending and receiving code in separate loops is a reasonable thing to do. You will need a bit of logic to handle a dropped connection, since you will need to pass the new connection information to both loops when the connection is re-established.