I’ve written a number of apps that use the TCPSocket connect to send plain text to third party servers and it works great. However, I now have an application where I want to send some HEX data (01 4E 30 54 49 09 30 30 30 46 09 30 30 30 43 32 41 04) and just putting that in the write method doesnt work.
So what do I need to do instead of TCPSocket1.Write(“01 4E 30 54 49 09 30 30 30 46 09 30 30 30 43 32 41 04”) ?
Have you tried using EncodeHex to encode the data you intend to send?
Var s As String
s = EncodeHex("The cake is a lie.", False)
// s is "5468652063616B652069732061206C69652E"
And I’m not sure without more information on the service and text you’re using, but text encodings are something to be wary of in nearly all aspects of text communication.
I have the HEX data i need to send already, this is the data I put in the post. I do not need to convert text to hex, i already have the hex. But I need to send it as HEX and not as text.
Hex is text or rather it it is numbers represented by teh code points that teh numbers reprinted as text would be.
What I am saying is that you are sending binary no matter what, be they code points that could be interested as text (and Hex numbers are numbers represented as text in a certain way) or binary representations of numbers directly as in the IEEE standards.
I need to send a HEX string, not the data that the HEX string represents.
When I put the hex string into the HEX field in packet sender (a standalone app i downloaded and run on my mac), and send it, the hardware responds to the comand as I would want it to. All I know, is that I am sending it as HEX and not as ASCII. If I switch to ASCII in packet sender, it doesnt work. So I know I need to send it as HEX.
As for the HEX string itself, it is structured as follows:
You are trying to send binary, which will allow you to include non-text characters like SOH and EOT. DecodeHex will convert your HEX into binary characters to transmit: