Valwex
Valwex
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Yup
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Do you have an example, please? Because I'm lost :x
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
For example, if I then want to read 3 bits from my byte stream, the ReadInt32BigEndian method won't advance the stream by 4 bytes, do you understand?
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Yes, it works, but I can't read several values in my byte stream
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Yes, except that there's no lib capable of reading a byte stream in little endian :/
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
I get 0x00000035 when using MemoryStream + BinaryReader and 0x35000000 when using BitStream
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
To keep things simple, the server will write a int32 at the beginning of the packet, which I must read to retrieve the value
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
I need to read negative values in the header variable because basically the packet id can be -1, -3 etc
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
// I get two different results here
// I would like to obtain the same result as header2 in header 1
var header1 = bitStream.Read32(32);
var header2 = BitConverterToInt32(binReader.ReadBytes(4));
// I get two different results here
// I would like to obtain the same result as header2 in header 1
var header1 = bitStream.Read32(32);
var header2 = BitConverterToInt32(binReader.ReadBytes(4));
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Yes, I get the same behavior, but from the moment I start reading 4 bytes I don't get the same values
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
I think it's a cast problem, yes, because in my code there are conditions that check whether the header variable corresponds to something and I never get to that condition, whereas if I use MemoryStream + BinaryReader it works
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Okay, but why get a different value in the console? If I use MemoryStream + BinaryReader or something else, I'll get the same values, but smaller
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Yep
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Basically I have this:
public static void Parse(byte[] buffer)
{
var stream = new ArrayByteStream(buffer);

var bitStream = new BitStream<ArrayByteStream>(stream);

// Reads 4 bytes and advances the position by 4 bytes
var header = bitstream.ReadInt32();

// Read 3 bits and advance position by 3 bits
var subchanIndex = bitstream.ReadBits(3);
}
public static void Parse(byte[] buffer)
{
var stream = new ArrayByteStream(buffer);

var bitStream = new BitStream<ArrayByteStream>(stream);

// Reads 4 bytes and advances the position by 4 bytes
var header = bitstream.ReadInt32();

// Read 3 bits and advance position by 3 bits
var subchanIndex = bitstream.ReadBits(3);
}
Except that the values I get are much larger than if I use MemoryStream + StreamReader
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Basically, I have a UDP client that must read packets sent to me by a UDP server In the stream I receive, I have to read both integers and bits In C#, we can only read bytes in a stream
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Yes, I know that we can read an int32 natively EXCEPT that in the rest of my code I have to read bits and we can't do that natively
55 replies
CC#
Created by Valwex on 7/28/2023 in #help
❔ Read bits from a byte[] array
Thanks for your answer In the library, using Read<int>() means that I want to read 32 bits (4 bytes), and advance the position by 4 bytes.
55 replies
CC#
Created by IcyIme on 7/17/2023 in #help
❔ problem with understanding delegates and generics
A delegate that encapsulates a single method is of little use in the end? The goal is to have lots of methods that a delegate will call
65 replies
CC#
Created by IcyIme on 7/17/2023 in #help
❔ problem with understanding delegates and generics
When should you use delegate instead of event?
65 replies