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(); }
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(); }
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 { } }