// /** // * File: Listener.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; using System.IO; using ln.http.connections; using ln.types.net; namespace ln.http.listener { public abstract class Listener : IDisposable { public IPv6 Listen { get; } public int Port { get; } public Endpoint LocalEndpoint => new Endpoint(Listen, Port); public abstract bool IsOpen { get; } protected Listener(IPv6 listen, int port) { Listen = listen; Port = port; } public virtual void AcceptMany(Action handler) { while (IsOpen) handler(Accept()); } public abstract void Open(); public abstract void Close(); public abstract Connection Accept(); public abstract void Dispose(); } }