2

I got some problem transfering Data via the BinaryWriter.

When I try to send

bw.Write(0x1a);
bw.Write(0xf8);
bw.Write(0x05);

It gets in the output to 0x00 - via

Client2Server._mainSock.Send(ms.ToArray());

What is causing this problem?

Greetings

Moritz
  • 153
  • 1
  • 9

1 Answers1

4

You are writing 3 integers here. Integers take 4 bytes, and in the cases shown, 3 of them are going to be zeros. Send bytes instead:

bw.Write((byte)0x1a);

of course, if you are writing bytes, then BinaryWriter is overkill - you could just use the Stream.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900