LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP

I am using a TCP/IP connection to communcate between executables. The communication is not constant, but it may occur every 10 seconds or in some situations it may occur every 1 second. The communication between the executables can be summed up like this:

 

1. The server is listening for connections.

2. The client opens a connection sends a command and possible some data to the server.

3. The server responds to the client to complete the communcation, possibly with some data but not nececarilly.

 

So I am unsure about whether I should close this connection after step 3, or should I keep it alive and have the server constatly reading until the next command and data is sent from client. Or should I close the connection and then just listen for a new client initiated connection again. Thanks for the help Smiley Happy

 

Anthony

0 Kudos
Message 1 of 4
(2,466 Views)

I recommend that you keep the connection open.  You may want to move the TCP handling into a separate loop (if it's not there already) and then whenever data is received, put it into a queue where it can be handled by the rest of your code.  Creating a new connection every time you want to send some data in either direction is not very efficient.

Message 2 of 4
(2,457 Views)

Okay, that makes sense. Thanks

0 Kudos
Message 3 of 4
(2,447 Views)

Yes, keep it open but you may want to add some code to re-connect if the connection is lost.

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