コード例 #1
0
        public AsyncTcpSession(IPEndPoint remoteIPEndPoint,
                               bool keepAlive, uint time, uint interval, bool reuseSocket = true)
            : this(AnyEndPoint, remoteIPEndPoint, keepAlive, time, interval, reuseSocket)
        {
            if (keepAlive)
            {
                WinSock2Wrapper.SetKeepAlive(base.Socket, true, time, interval);
            }

            CreateConnectSaea();
        }
コード例 #2
0
        public AsyncTcpSession(IPEndPoint localIPEndPoint, IPEndPoint remoteIPEndPoint,
                               bool keepAlive, uint time, uint interval, bool reuseSocket = true)
            : base(SessionType.Tcp, remoteIPEndPoint, reuseSocket)
        {
            base.LocalEndPoint = localIPEndPoint;

            if (keepAlive)
            {
                WinSock2Wrapper.SetKeepAlive(base.Socket, true, time, interval);
            }
            CreateConnectSaea();
        }
コード例 #3
0
        protected void CheckPendingSocketsTimeout(object arg)
        {
            try
            {
                LinkedList <Socket> list = new LinkedList <Socket>();

                lock (_pendingSockets)
                {
                    foreach (Socket socket in _pendingSockets)
                    {
                        try
                        {
                            if (WinSock2Wrapper.GetConnectTime(socket) >= CONNECTED_NO_DATA_TIMEOUT_SECONDS)
                            {
                                list.AddLast(socket);
                                _pendingSockets.Remove(socket);
                            }
                        }
                        catch
                        {
                        }
                    }
                }

                foreach (Socket socket in list)
                {
                    try
                    {
                        socket.Disconnect(true);
                    }
                    catch
                    {
                    }

                    lock (_reuseSocketQueue)
                    {
                        _reuseSocketQueue.Enqueue(socket);
                    }
                }
            }
            catch
            {
            }
        }