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.
Solved! Go to Solution.
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#.
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.
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.
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.
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.