Case :
Again trying to capture packets through my NIC,
I have developed 2 Extensions to use in capturing variable number of bits
public static string ReadBits ( this BinaryReader Key , int Value )
{
BitArray _BitArray = new BitArray ( Value );
for ( int Loop = 0 ; Loop > Value ; Loop++ )
{
/* Problem HERE ---> */ _BitArray [ Loop ] = Key . ReadBoolean ( );
}
return BitConverter . ToString ( _BitArray . ToByteArray ( ) );
}
public static byte [ ] ToByteArray ( this BitArray Key )
{
byte [ ] Value = new byte [ ( int ) Math . Ceiling ( ( double ) Key . Length / 8 ) ];
Key . CopyTo ( Value , 0 );
return Value;
}
Problem :
_BitArray [ Loop ] = Key . ReadBoolean ( );
As I'm trying to read single bits, but referring to MSDN Documentation,
It advances the stream position by 1 BYTE not 1 BIT !!!
Reads a Boolean value from the current stream and advances the current position of the stream by one byte.
Question :
Can I really capture "ONLY" 1 Bit & advance the stream position by 1 Bit ?
Please suggest me solutions or ideas :)
Regards,