// /** // * File: HttpListener.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use wihtout proper permission is illegal and may lead to legal actions. // * // * // **/ using System.Net.Sockets; using ln.type; using ln.http.connections; namespace ln.http.listener { public class HttpListener : Listener { protected TcpListener tcpListener; public HttpListener(int port) :this(IPv6.ANY,port){} public HttpListener(Endpoint endpoint) : this(endpoint.Address, endpoint.Port) {} public HttpListener(IPv6 listen, int port) : base(listen, port) { } public override Connection Accept() => new HttpConnection(this,tcpListener.AcceptTcpClient()); public override bool IsOpen => (tcpListener != null); public override void Open() { tcpListener = new TcpListener(Listen, Port); tcpListener.Start(); } public override void Close() { if (tcpListener != null) { tcpListener.Stop(); tcpListener = null; } } public override void Dispose() { if (IsOpen) Close(); } } }