public void CloseOneConnection(FastSocketConnection fastSocketConnection) { if (fastSocketConnection != null) { fastSocketConnection.Close(); } }
private void HandleListenAsync() { if (this.IsListen) { this.socket.BeginAccept(asyncResult => { try { Socket newConnectionSocket = this.socket?.EndAccept(asyncResult); if (this.IsListen) { this.HandleListenAsync(); } else { newConnectionSocket.Close(); return; } if (this.Connections.Count(p => p.Enable) >= this.MaxConnections) { newConnectionSocket.Close(); return; } else { FastSocketConnection fastSocketConnection = new FastSocketConnection(newConnectionSocket, (int)asyncResult.AsyncState, this); fastSocketConnection.Start(); } } catch (Exception ex) { this.FastSocketService.OnServiceException(this, ex); } }, this.AutoGrowthConnectionId++); } }