Exemple #1
0
        static void Listen(IAsyncResult ar)
        {
            try
            {
                Socket skt = svrSkt.EndAccept(ar);
                svrSkt.BeginAccept(Listen, null);

                var psr = new ClientProcessor(skt);
                processors.Add(psr);
                psr.BeginProcess();
            }
            catch (ObjectDisposedException)
            {
            }
        }
Exemple #2
0
 static void Listen(IAsyncResult ar)
 {
     Socket skt = null;
     try
     {
         skt = svrSkt.EndAccept(ar);
     }
     catch (ObjectDisposedException)
     {
     }
     try
     {
         svrSkt.BeginAccept(Listen, null);
     }
     catch (ObjectDisposedException)
     {
     }
     if (skt != null)
     {
         var psr = new ClientProcessor(skt);
         psr.BeginProcess();
     }
 }
Exemple #3
0
 public void Read(ClientProcessor psr, byte[] body, int len)
 {
     Read(psr, new NReader(new MemoryStream(Crypt(psr, body, len))));
 }
Exemple #4
0
 public abstract byte[] Crypt(ClientProcessor psr, byte[] dat, int len);
Exemple #5
0
 protected override void Write(ClientProcessor psr, NWriter wtr)
 {
 }
Exemple #6
0
 protected override void Read(ClientProcessor psr, NReader rdr)
 {
 }
Exemple #7
0
 public override byte[] Crypt(ClientProcessor psr, byte[] dat, int len)
 {
     return dat;
 }
Exemple #8
0
 protected abstract void Write(ClientProcessor psr, NWriter wtr);
Exemple #9
0
 protected abstract void Read(ClientProcessor psr, NReader rdr);
Exemple #10
0
        public byte[] Write(ClientProcessor psr)
        {
            MemoryStream s = new MemoryStream();
            this.Write(psr, new NWriter(s));

            byte[] content = s.ToArray();
            byte[] ret = new byte[5 + content.Length];
            content = this.Crypt(psr, content, content.Length);
            Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(ret.Length)), 0, ret, 0, 4);
            ret[4] = (byte)this.ID;
            Buffer.BlockCopy(content, 0, ret, 5, content.Length);
            return ret;
        }