02-23-2011 11:23 AM
Hi,
I'm having trouble with the TCP connection. My computer I am working on will be the server, or the listener, which is trying to connect with a linux based computer. I am able to successfully create a connection using TCP listen. When I am trying the TCP read, I am getting an error 56. I understand it is with the timing. I also tried to run the program with an unlimited amount of time (-1), but this did not seem to resolve the issue. I've attached the screen shots of the code. Server_Listen is the connection to initiate the listening, and Server_Read illustrates how my read is implemented.
Help? 🙂
Thanks,
Andrea
02-23-2011 11:35 AM
More likely than not you are not receiving 20 bytes of data. Your read is expecting to receive 20 bytes. If you don't you will get a timeout error and the whatever data that you did read will be returned. If you set the timeout to -1 you will read forever until 20 bytes are received. It is quite common in network applications to get a timeout when you don't know how much data you will be receiving. You use this timeout to determine if you did receive a block of data. Further processing can determine if you received the complete data or not. In cases where you have a protocol you need to read data according to the defined protocol. A very common and simple protocol would send a 4 byte value indicating the amount of data to follow. In a case like this read 4 bytes, convert it to an integer and use this as the amount of data for the next read.
02-23-2011 01:04 PM
The method Mark suggested can be seen in the "Simple Data Client" and "Simple Data Server" examples that ship with LabVIEW. Just open the Example Finder (Help -> Find Examples) and search for "tcp/ip".
02-23-2011 01:27 PM
I can't seem to read 4 bytes ... What does this generally mean? I know I can initiate a listen. Not sure the meaning of this.
Thanks,
Andrea
02-23-2011 01:57 PM
This could mean that the device sending the data to you is sending less than 4 bytes. You need to look at the specifics of the device you are talking to regarding what data and how itis formated will be communicated. The example I gave above was simply that, an example. It more than likely does not match your specific device.
Try reading 1 byte at a time until you get a timeout. This will at least help you to see what data is there. When you did get a timeout did you look at the returned data? Was there anything there or are you reading nothing.
03-08-2012 05:32 PM
Hi everyone,
I'm also having a problem with my TCP Read: using the Highlight execution I can see that Labview is communicating - no 'error out' - , but my 'bytes written' are always zero, no matter what type of data I send!
What could be the source of this problem?
Thank you,
M. Assad
03-09-2012 08:34 AM
When I worked this awhile ago, I found I had an issue with my receiving end. Not sure if it helps - maybe someone can enlighten the specifics of your issue.
03-09-2012 11:40 AM
Andrea,
Thank you for your reply! I've found out that my code works only with double variables - not sure why...
Now I'm trying to receive multiple signals (from two different sensors), any thoughts on that?