LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP - send & receive message in real time

Hi,

 

I have developed a code to send and receive message using TCP Protocol. I am able to send message from TCPServerduplex.vi and it gets displayed on TCPClientduplex.vi. But vice versa is not happening. Kindly help me resolve this issue. Thank you in advance. Attaching both the vi.

 

Download All
0 Kudos
Message 1 of 4
(1,921 Views)

In the TCPClientduplex you try to read 50 characters. If you don't send 50 characters, that read will fail.

 

I'd set the reads to CRLF mode, and paste a \r\n after everything I write. Instant synchronization...

 

AFAIK, Usually you call the listener side the server, as it 'servers' the connection... This is not related to who instantiates the contact, or who starts reading or writing.

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

Also, you should close the Listener Id reference. You get problems if you don't: memory leaks, but also "connection also in use" errors.

0 Kudos
Message 3 of 4
(1,882 Views)

Generally, you should not be constantly opening and closing your connections.  You should connect and start talking until one of them closes the connection.  I often use a State Machine to handle my TCP/IP connections.  This way you can easily go back to setting up a connection when a connection is lost.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(1,850 Views)