public bool CloseConnection(string handle) { lock (m_Connections) { //System.Diagnostics.Debug.WriteLine("Connections before:" + m_Connections.Count.ToString()); if (m_Connections.Contains(handle)) { s2hConnection conn = (s2hConnection)m_Connections[handle]; m_Connections.Remove(handle); try { conn.Close(); } catch (Exception) {} //System.Diagnostics.Debug.WriteLine("Connections after:" + m_Connections.Count.ToString()); return(true); } } return(false); }
public s2h.s2h_errors CreateConnection(string host, int port, out s2hConnection conn) { SocksOverHttp.s2h.s2h_errors iRes; Socket socket = null; conn = new s2hConnection(); iRes = conn.Connect(host, port, out socket); if (iRes != s2h.s2h_errors.s2h_ok) { try { conn.Close(); } catch (Exception) {} conn = null; } lock (m_Connections) { m_Connections.Add(conn.handle, conn); } return(iRes); }