예제 #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)
            {
            }
        }
예제 #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();
     }
 }
예제 #3
0
 public void Read(ClientProcessor psr, byte[] body, int len)
 {
     Read(psr, new NReader(new MemoryStream(Crypt(psr, body, len))));
 }
예제 #4
0
 public abstract byte[] Crypt(ClientProcessor psr, byte[] dat, int len);
예제 #5
0
 protected override void Write(ClientProcessor psr, NWriter wtr)
 {
 }
예제 #6
0
 protected override void Read(ClientProcessor psr, NReader rdr)
 {
 }
예제 #7
0
 public override byte[] Crypt(ClientProcessor psr, byte[] dat, int len)
 {
     return dat;
 }
예제 #8
0
 protected abstract void Write(ClientProcessor psr, NWriter wtr);
예제 #9
0
 protected abstract void Read(ClientProcessor psr, NReader rdr);
예제 #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;
        }