Archived Forum Post

Index of archived forum posts

Question:

Chilkat.Socket -> any way to transmit and receive binary.

Sep 10 '12 at 21:39

Issue being is that characters are being lost in the higher ranges, and UTF-8 is not a possibility on the receiving end. They currenlty transmit RAW binary data with no character set correlation. I see no way of doing this on socket side using SendString, ReceiveString, SendBytes, ReceiveBytes. Even though the later SendBytes and ReceiveBytes say that Character Sets are not used it seems to default to a Unicode setting by default... meaning it just can not be changed from that setting unlike the SendString and ReceiveString... So back to the deal, need to send information in binary form as handed to the Chilkat without any chracter manipulation.


Answer

Mike,

SendBytes and ReceiveBytes do not treat the data as characters. The exact binary bytes provided by the app are sent (for SendBytes) and the exact bytes received by ReceiveBytes are returned, with no manipulation.


Answer

I don't know if CkSocket has any methods for this.... maybe this is a case of (I believe it is called) network byte order. Perhaps the high-order bytes and low-order bytes have "flipped"?

http://en.wikipedia.org/wiki/Endianness

I am sure Matt knows what I am talking about ;-)

PS. Windows to Windows should not be a problem (or better Intel to Intel) as they use the same byte order. If this is between different OS's (or actually hardware architecture), that would be what I look for. The sending (likely) or receiving party is not properly converting to/from network byte order.

This article explains it quite well: http://msdn.microsoft.com/en-us/library/aa271863%28v=vs.60%29.aspx


Answer

Thanks Gert!

You are correct if the binary data represents integer or numerical values such as 16/32/64-bit integers, floating point values, etc.) If the data is simply bytes, such as image data, video, or anything else, then there is no byte order.