简体   繁体   中英

TCP socket and binary data

How to send 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM