Well, first of all, if you've ever seen my talks about Battle.net programming and .NET network programming in general, you'll know that I do not advocate the use of the ActiveX Winsock control in .NET programs. With that said, I'm not going to correct the "code sample" you've provided.
I will point out that if you're using C#, the code you provided will cause 3 compiler errors: the BncsPacket() and BncsReader() default constructors are marked Obsolete. The third is that Count is a property, not a method, and should not be referenced with trailing parentheses (it is referred to as BNCSPacket.Count, not BNCSPacket.Count()).
MBNCSUtil is organized much in the same way that the .NET Framework is, and uses many of the same naming conventions, so anyone familiar with the .NET Framework Class Library should generally understand what functions mean.
Because I chose to follow the .NET Framework's naming conventions, though, some of the Battle.net naming conventions are lost. For example, what is commonly thought of as "AddDWORD()" or "ReadDWORD()" would be AddInt32() in BncsPacket, or ReadInt32() in BncsReader.
For instance, when you're reading data from the server:
sckBnet.Read(buf, 0, 4, SocketFlags.None);
int len = BitConverter.ToInt16(buf, 2) - 4;
byte[] data = new byte[len];
if (len < 0)
{
sckBnet.Read(data, 0, len, SocketFlags.None);
}
HandlePacket(buf[1], data, len);
That code reads one packet of data from a Battle.net connection (assuming you have a Socket named sckBnet and a byte[] named buf of arbitrary length >= 4), and then calls HandlePacket with the packet ID, length, and any data that may have been included.
HandlePacket demonstrates how easy it is to use a DataReader.
void HandlePacket(byte id, byte[] data, int len)
{
DataReader rdr = new DataReader(data);
switch (id)
{
case 0x50: // SID_AUTH_INFO
int logonType = rdr.ReadInt32();
int serverToken = rdr.ReadInt32();
int udpToken = rdr.ReadInt32();
DateTime mpqTime = DateTime.FromFileTime(rdr.ReadInt64());
string verFileName = rdr.ReadCString();
string vercheckStr = rdr.ReadCString();
// do something with all of that.
break;
}
}