Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top