Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binary Header on ASCII Transmission - Problems
Message
 
 
To
24/09/2005 09:48:25
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP
Network:
Novell 5.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01052700
Message ID:
01052717
Views:
14
WAG. I would try
lcSendMessage = CHR(LEN(lcASCIIMessage)) + CHR(0) + lcASCIIMessage
>I am having problems attaching a binary header(2 bytes that signify the length of the ASCII message) to the rest of the ASCII message properly. I am using a Winsock ActiveX TCPConrol Object to handle the communication. Here is my problem:
>
>I need to concatenate the 2 Header bytes to the ASCII message because the Server application expects it that way. The size of the ASCII message will always be between 200 and 210 bytes. Again, the 2 Header bytes is just supposed to be a binary representation of the length of the ASCII message. Here's what I'm seeing:
>
>If the ASCII message was 210 bytes, I would want to attach 2 bytes that represent the 16-bit integer 210 ->
>
>00000000 11010010
>
>to the front of the message. I am attempting to do this by using the CHR() command to create these bytes as that gives me a convenient format for attaching it to the ASCII message. From my understanding of characters and bytes, I should be able to emulate both of the above bytes by using ->
>
>CHR(0) and CHR(210)
>
>so literally, here is the code I'm using:
>
>lcSendMessage = CHR(0) + CHR(LEN(lcASCIIMessage)) + lcASCIIMessage
>
>My problem stems from the leftmost byte always being CHR(0) or 00000000 because the size of the ASCII message will never exceed 256. I notice the problem when viewing the transmission using Ethereal. For some reason, the 00000000 at the beginning of the message is getting read as a NULL(I do realize CHR(0) is a NULL) and causing all of the following bytes(211 in this case) to be set to 0 in the Data segment of the TCP transmission. What I really think is strange is that the size of the data segment is correct, 212 total bytes, but all are showing as zeroes. If I just leave off the leftmost header byte(making the header only one byte) then the rest of the message seems to be created/sent fine(i.e. lcSendMessage = CHR(LEN(lcASCIIMessage)) + lcAsciiMessage)
>
>I've attempted using CreateBinary() to get around this problem, figuring that if I called CreateBinary() on the header portion and attached *that* to the ASCII message that all would be fine, but I'm actually having a hard time because CreateBinary() doesn't seem to be acting as I expected it to. Perhaps I am not using that command correctly here or perhaps I don't even need to use it.
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform