Пример #1
0
 protected void InitSocket()
 {
     //if (Socket == null)
     //{
     Socket = SocketHelper.GetSocket(ConnectType.TCP);
     //}
 }
Пример #2
0
        public static T GetSocketEntity <T>(IPEndPoint ipEndPoint, ConnectType type) where T : SocketEntity, new()
        {
            Socket socket = SocketHelper.GetSocket(type);
            T      entity = new T();

            entity.Socket     = socket;
            entity.IpEndPoint = ipEndPoint;
            return(entity);
        }
Пример #3
0
 /// <summary>
 /// 获取数据后处理
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="len"></param>
 /// <returns></returns>
 protected byte[] ParseData(byte[] data, int len)
 {
     try
     {
         //根据获取的数据的长度,重新创建一个byte[]保存实际数据
         data = SocketHelper.GetSubArray(data, 0, len);
         if (Protocol != null)
         {
             data = Protocol.Parse(data, this);
         }
     }
     catch (Exception ex)
     {
         Log.error(ex);
     }
     return(data);
 }
Пример #4
0
 public int SendMsg(string strMsg, object arg, AsyncCallback callback)
 {
     byte[] bytes = SocketHelper.GetBytesEx(strMsg, Encoding);
     return(SendMsg(bytes, arg, callback));
 }
Пример #5
0
 public override int SendMsg(string strMsg, object arg)
 {
     byte[] bytes = SocketHelper.GetBytesEx(strMsg, Encoding);
     return(SendMsg(bytes, arg));
 }
Пример #6
0
 protected void InitSocket()
 {
     this.Socket = SocketHelper.GetSocket(ConnectType.UDP);
 }