11-17-2009 07:53 AM - edited 11-17-2009 07:55 AM
Hello,
I am trying to establish a simple TCP/IP connection to local host itself. The Server program is sending a string(example: Hello123456). I am receiving only a part of the string(ello123456) and also receiving an error, "Error 66 occurred at TCP Read".
The peer side of the code is in java. I am sure that the peer side of the code does not close the connection, because I have kept enough time delay before it attempts to close the connection. I have also changed the options at Tools-> Options->VI Server with Port = 0 and enabled the TCP/IP connection.
I have attached a screen shot of error received (using Probe) and the Vi.
Kindly advise.
Regards,
H.
11-17-2009 08:01 AM
11-17-2009 08:29 AM
11-17-2009 11:19 PM
11-17-2009 11:53 PM
11-18-2009 02:05 AM
11-18-2009 08:00 AM
Hello Muks,
I have checked out most of the online resourses, but I am not able to find out a solution. Attached to my first post is a screen shot of the VI in the debug mode. I am receiving data sent by the 'server code' except for the first character and error 66.
Regards,
-H.
11-18-2009 12:21 PM
What are you doing on the TCP server side?
The code you have is set up to read 1 byte, and use that to determine how many more bytes to read. This is a common way of determining how much data to try to read when the length of the data string could vary. Well, you don't have any data size prepended to the front of your string. You are reading 1 bytes (which is the H) and typecasting that to a number (decimal 72) and trying to read those 72 bytes. What you get is the remainder of the string (since the H has already been read). But the string isn't long enough so you get an error.
11-23-2009 08:56 AM - edited 11-23-2009 08:56 AM
Hello Ravens Fan!
Thank you for your mail. I see the problem now. I have improved on the design by perpending the string length before the string and sending it over. The TCP read first reads the 1st Byte (which is the string length), converts it to an Integer (by using Digital String to Number) which is then fed into the Bytes to Read of the next TCP Read. (As shown in the attached Vi)
My question is: Is prepending the length of the string before the actual string, the only way to read strings of variable length?
Thanks,
Regards
H
11-23-2009 10:55 AM