public TcpConnectionListener(string LocalIp, int Port, TcpConnectionManager Manager) { IPAddress IP = null; if (!IPAddress.TryParse(LocalIp, out IP)) { IP = IPAddress.Loopback; UberEnvironment.GetLogging().WriteLine("[TCPListener.Construct]: Could not bind to " + LocalIp + ", binding to " + IPAddress.Loopback.ToString() + " instead.", LogLevel.Error); } this.Listener = new TcpListener(IP, Port); this.ConnectionReqCallback = new AsyncCallback(ConnectionRequest); this.Factory = new TcpConnectionFactory(); this.Manager = Manager; }
public void Destroy() { try { Stop(); Listener = null; Manager = null; Factory = null; GC.Collect(); } catch { Console.WriteLine("Could not destroy the Listener,Manager, and Factory. Collecting Garbage - Failed."); } finally { Console.WriteLine("Destroyed The TcpConnectionListener Class. Collected Garbage Successfully."); } }