Beispiel #1
0
        private void ReadAndProcessProcPacket(IAsyncResult R)
        {
            Connection conn = (Connection)R.AsyncState;

            while (!R.IsCompleted)
            {
                ;
            }
            conn.Soc.EndReceive(R);
            UInt16 ExecCode = BitConverter.ToUInt16(conn.buffer, 0);

            if (CommandsList.VerifyCommandExists(ExecCode))
            {
                Int64  ArgsSize  = BitConverter.ToInt64(conn.buffer, 2);
                string AsciiArgs = "";
                if (ArgsSize > 0)
                {
                    conn.buffer = new byte[ArgsSize];
                    conn.Soc.Receive(conn.buffer);
                    AsciiArgs = Encoding.ASCII.GetString(conn.buffer);
                }

                conn.Soc.Send(BitConverter.GetBytes(ServerCodes.Success));
                ReturnStream RS = new ReturnStream(conn.Soc);
                CommandsList.Execute(ExecCode, AsciiArgs, RS);
                RS.Close();
            }
            else
            {
                conn.Soc.Send(BitConverter.GetBytes(ServerCodes.InvalidCommandCode));
            }
        }