internal static void RemoveEndPoint(EndPointListener listener) { lock (((ICollection)_addressToEndpoints).SyncRoot) { var addr = listener.Address; var eps = _addressToEndpoints[addr]; eps.Remove(listener.Port); if (eps.Count == 0) { _addressToEndpoints.Remove(addr); } listener.Close(); } }
private string checkIfCertificateExists() { if (!_secure) { return(null); } var usr = _listener.SslConfiguration.ServerCertificate != null; var port = EndPointListener.CertificateExists(_port, _listener.CertificateFolderPath); if (usr && port) { _logger.Warn("The server certificate associated with the port number already exists."); return(null); } return(!(usr || port) ? "The secure connection requires a server certificate." : null); }
private static void processAccepted(Socket socket, EndPointListener listener) { HttpConnection conn = null; try { conn = new HttpConnection(socket, listener); lock (listener._unregisteredSync) listener._unregistered[conn] = conn; conn.BeginReadRequest(); } catch { if (conn != null) { conn.Close(true); return; } socket.Close(); } }
private static EndPointListener getEndPointListener( HttpListenerPrefix prefix, HttpListener listener) { var addr = convertToIPAddress(prefix.Host); Dictionary <int, EndPointListener> eps; if (_addressToEndpoints.ContainsKey(addr)) { eps = _addressToEndpoints[addr]; } else { eps = new Dictionary <int, EndPointListener> (); _addressToEndpoints[addr] = eps; } var port = prefix.Port; EndPointListener lsnr; if (eps.ContainsKey(port)) { lsnr = eps[port]; } else { lsnr = new EndPointListener( addr, port, listener.ReuseAddress, prefix.IsSecure, listener.CertificateFolderPath, listener.SslConfiguration); eps[port] = lsnr; } return(lsnr); }