LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Client Not writing until connection is closed

Solved!
Go to solution

Hey guys,

 

I am building a test TCP client in LabView connecting to a TCP server built in C#. I connect successfully to the server, however, the write string from LabVIEW's write block does not get sent to the server until the connection is closed. Thus my read block times out since the server has not received any data.

 

The architecture is as follows:

Client connects > Client sends data > Server replies with data after 1-2 seconds from command received > connection closes

 

I'm completely new to LabView, as in I just installed it. I looked at numerous of online resources and read the documentation on the TCP read/write blocks and I can't see what I'm doing wrong with the write block.

 

labviewTCPClient.png

 

 

0 Kudos
Message 1 of 7
(2,318 Views)

Do you need to send a termination character?

 

It is hard to comment because the answer depends on how the TCP server was written in C#.

Message 2 of 7
(2,312 Views)

My server is async and I'm using ReadLineAsync() to read the end of line.

0 Kudos
Message 3 of 7
(2,292 Views)
Solution
Accepted by topic author CNegru

How does it know when it has read a complete line?  I would assume it is looking for a termination character, but I don't see one in the string you are sending.

Message 4 of 7
(2,270 Views)
Solution
Accepted by topic author CNegru

RavensFan is right.  You need a termination character appended at the end of your sent string.  I believe ReadLineAsync() will accept carriage return, line feed, or both.


using LV2017SP1
Message 5 of 7
(2,266 Views)

While we're giving advice, let's take a look at your error handling.  If you have more than one error handler, generally speaking, you're doing something wrong.  That's the case here.  Instead of having multiple error handlers, wire the error wire itself into the case structure.  This will give you a case structure with two cases: error and no error.  You'll be able to write cleaner code that operates differently depending on if you have an error or not.

Message 6 of 7
(2,262 Views)

Hey guys, THANK YOU SO MUCH. I tried sending a CR and /or LF and nothing worked. I then used the LabVIEW "end of line constant" and it worked. This is just me being new to Labview.

0 Kudos
Message 7 of 7
(2,229 Views)