TCP socket and binary data
How to 开发者_如何学Gosend binary data (01110110 for exemple) with C# throught a TCP (using SSL) socket ?
I'm using :
SslStream.Write()
and
h[0] = (byte)Convert.ToByte("01110110");
isn't working
You need to be a little clearer about what 01110110
is. Is it decimal? Hex? Binary? Note that "binary data" can be represented in any base.
Since it's 8 digits of 0 and 1, and since you used the word "binary" in your question, I'm going to guess that it's binary, which is 118
decimal (google for 0b0111010 in decimal
).
So you can just do
h[0] = 118;
My feeling is that you'll need to learn a bit more about the basics of how bytes work and the binary system before you'll be able to make much further progress. A good beginning programming book should help.
精彩评论