Ejemplo n.º 1
0
 //发送
 public void Send(Protocol.ProtocolBase protocol)
 {
     byte[] bytes    = protocol.Encode();
     byte[] length   = BitConverter.GetBytes(bytes.Length);
     byte[] sendbuff = length.Concat(bytes).ToArray();
     try
     {
         this.socket.BeginSend(sendbuff, 0, sendbuff.Length, SocketFlags.None, null, null);
     }
     catch (Exception e)
     {
         Console.WriteLine("[发送消息]" + this.GetAdress() + " : " + e.Message);
     }
 }