예제 #1
0
        private void M_socket_OnSocketStatusChangedEvent(object arg1, SocketStatusChangedArgs <ProtocolPackageBase> arg2)
        {
            Console.WriteLine("TCP-Client连接状态改变:" + arg2.Status);


            //展示处理TCP的断线重连
            if (m_socket.NetProtocolType == EnumNetworkType.TCP)
            {
                if (arg2.Status == EnumNetworkStatus.Shutdown && !m_socket.Disposed)
                {
                    new Thread(new ThreadStart(() =>
                    {
                        try
                        {
                            //休眠5s,避免不断重连,
                            Thread.Sleep(5000);
                            m_socket.Create();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("TCP-Client重连失败");
                        }
                    })).Start();
                }
            }
        }
예제 #2
0
 private void M_socket_OnSocketStatusChangedEvent(object arg1, SocketStatusChangedArgs <ProtocolPackageBase> arg2)
 {
     Console.WriteLine("UDP状态改变:" + arg2.Status);
 }
예제 #3
0
 private void M_socket_OnClientSocketStatusChangedEvent(object arg1, SocketStatusChangedArgs <ProtocolPackageBase> arg2)
 {
     Console.WriteLine(string.Format("服务的的客户端状态改变:{0}    {1}", arg2.Target.RemoteEndPoint, arg2.Status));
 }