开发者

TCP socket and binary data

开发者 https://www.devze.com 2022-12-25 20:15 出处:网络
How to 开发者_如何学Gosend binary data (01110110 for exemple) with C# throught a TCP (using SSL) socket ?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消