/// <summary>
        /// Create an instance of an endpoint listener for the specified endpoint definition.
        /// </summary>
        /// <param name="endpointDefinition">The endpoint definition to create the listener for.</param>
        /// <returns>The endpoint listener for the specified endpoint definition.</returns>
        public virtual IEndpointListener CreateListener(IEndpointDefinition endpointDefinition)
        {
            var tcpListener = new TcpListener(endpointDefinition.Endpoint);

            tcpListener.Start();

            var endpointEventArgs = new EndpointEventArgs(endpointDefinition, tcpListener.LocalEndpoint);

            OnEndpointStarted(endpointEventArgs);

            return(new EndpointListener(tcpListener, () => OnEndpointStopped(endpointEventArgs)));
        }
 /// <summary>
 /// Raises the EndPointStopped Event.
 /// </summary>
 /// <param name="args">The event data.</param>
 protected virtual void OnEndpointStopped(EndpointEventArgs args)
 {
     EndpointStopped?.Invoke(this, args);
 }