예제 #1
0
        /// <summary>
        ///     向服务器发送数据,最基础和原始的
        /// </summary>
        /// <param name="stateBase">StateBase</param>
        /// <param name="data">发送的数据</param>
        internal override void Send(StateBase stateBase, byte[] data)
        {
            if (stateBase == null)
            {
                return;
            }
            Socket handler = stateBase.WorkSocket;

            StickPackage.EncryptionPackage(ref data);
            try
            {
                handler.BeginSend(data, 0, data.Length, 0, SendCallback, handler);
            }
            catch
            {
            }
        }
예제 #2
0
        /// <summary>
        /// 向服务器发送数据,最基础和原始的
        /// </summary>
        /// <param name="stateBase">StateBase</param>
        /// <param name="data">发送的数据</param>
        override internal void Send(TransmitData stateBase, byte[] data) //实现客户端虚方法
        {
            if (stateBase == null)
            {
                return;
            }
            Socket handler = stateBase.WorkSocket;

            //对data数据进行粘包加密
            StickPackage.EncryptionPackage(ref data);
            try
            {
                //发送
                handler.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), handler);
            }
            catch
            {
            }
        }
예제 #3
0
 /// <summary>
 /// 向客户端发送数据,最基础的发送
 /// </summary>
 /// <param name="stateBase">TcpState</param>
 /// <param name="data">发送的数据</param>
 override internal void Send(StateBase stateBase, byte[] data)
 {
     if (stateBase == null)
     {
         return;
     }
     StickPackage.EncryptionPackage(ref data);
     //MessageBox.Show(data.Length.ToString()+"你好"+data[9].ToString());
     try
     {
         stateBase.WorkSocket.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), stateBase);
     }
     catch (Exception Ex)
     {
         int i = Ex.Message.IndexOf("远程主机强迫关闭了一个现有的连接");
         if (i != -1)
         {
             TcpState stateOne = IPEndPointToState(stateBase.IpEndPoint);
             socketRemove(stateOne, Ex.Message);
         }
     }
 }