Code:
try
{
sock = this.LoginSocket.Accept();
}
catch (Exception)
{
Console.WriteLine("> Terminating The Server");
this.LoginSocket.Close();
}
Accept() can fail (throw an exception) even if the server is still running perfectly fine. If someone disconnects and connects clients rapidly, this can happen.
Quote:
|
new Thread(new ThreadStart(socket2.Run)).Start();
|
Although it's an auth server, and it will never have many connections at the same time stay alive for very long, it's a bad idea to give each client it's own thread, use System.Net.Sockets.Socket.BeginReceive()
Quote:
if (length < 1000)
{
destinationArray = new byte[length];
Array.Copy(this.CSocketBuffer, destinationArray, length);
|
300 is more precise (still not exact, can't be bothered to go find out the exact size, its liek 276 or something), but I suppose that doesn't matter.
Quote:
case 1051:
case 1086:
RequestLogin(Data, CSocket, ClientIP);
break;
|
This is wrong, only case 0x41B, or 1051 should be replied to.
Quote:
if (Data.Length == 52)
{
Array.Copy(Data, 20, destinationArray, 0, 16);
str3 = Encoding.ASCII.GetString(Data, 36, 16).Replace("\0", "");
}
|
This should
never occur unless someone is using an old client, which they shouldn't be.
Just a few things I decided to point out.