/// <summary> /// The loop for the internal Thread that listens for connections. /// </summary> private void Run() { LogSocketReader reader; do { reader = GetReader(); } while ((reader != null) && LogSocketReaderReceiver.ReaderReady(reader)); LogSocketReaderReceiver.ListenerClosed(); }
/// <summary> /// Create a new instance of Listener. /// </summary> /// <remarks> /// An exception may be raised if there is a problem /// opening the server socket on the specified port. /// </remarks> /// <param name="anIpAddress">The IP address on which a port will be opened to listen</param> /// <param name="aPort">A port number on which to listen</param> /// <param name="aReceiver">A LogSocketReaderReceiver</param> internal Listener(IPAddress anIpAddress, int aPort, LogSocketReaderReceiver aReceiver) { Port = aPort; IpAddress = anIpAddress; // exceptions will be thrown if there is a problem with the port TcpListener = new TcpListener(IpAddress, Port); TcpListener.Start(); LogSocketReaderReceiver = aReceiver; Thread = new Thread(new ThreadStart(Run)); Thread.IsBackground = true; Thread.Start(); }
/// <summary> /// Create a new Listener and start listening on the port. /// </summary> /// <remarks> /// An exception may be raised if there is a problem /// opening the server socket on the specified port. /// </remarks> /// <param name="anIpAddress">The IP address on which to listen.</param> /// <param name="aPort">The port on which to listen.</param> /// <param name="aReceiver">A LogSocketReaderReceiver that will be notified of new connections.</param> /// <returns>A Listener.</returns> public static Listener StartListening(IPAddress anIpAddress, int aPort, LogSocketReaderReceiver aReceiver) { return(new Listener(anIpAddress, aPort, aReceiver)); }
/// <summary> /// Create a new Listener and start listening on the port. /// </summary> /// <remarks> /// An exception may be raised if there is a problem /// opening the server socket on the specified port. /// </remarks> /// <param name="aPort">The port on which to listen.</param> /// <param name="aReceiver">A LogSocketReaderReceiver that will be notified of new connections.</param> /// <returns>A Listener.</returns> public static Listener StartListening(int aPort, LogSocketReaderReceiver aReceiver) { return(new Listener(aPort, aReceiver)); }
/// <summary> /// Create a new instance of Listener listening on any IP address /// </summary> /// <remarks> /// An exception may be raised if there is a problem /// opening the server socket on the specified port. /// </remarks> /// <param name="aPort">A port number on which to listen</param> /// <param name="aReceiver">A LogSocketReaderReceiver</param> internal Listener(int aPort, LogSocketReaderReceiver aReceiver) : this(IPAddress.Any, aPort, aReceiver) { }
/// <summary> /// Create a new Listener and start listening on the port. /// </summary> /// <remarks> /// An exception may be raised if there is a problem /// opening the server socket on the specified port. /// </remarks> /// <param name="anIpAddress">The IP address on which to listen.</param> /// <param name="aPort">The port on which to listen.</param> /// <param name="aReceiver">A LogSocketReaderReceiver that will be notified of new connections.</param> /// <returns>A Listener.</returns> public static Listener StartListening(IPAddress anIpAddress, int aPort, LogSocketReaderReceiver aReceiver) { return new Listener( anIpAddress, aPort, aReceiver); }
/// <summary> /// Create a new Listener and start listening on the port. /// </summary> /// <remarks> /// An exception may be raised if there is a problem /// opening the server socket on the specified port. /// </remarks> /// <param name="aPort">The port on which to listen.</param> /// <param name="aReceiver">A LogSocketReaderReceiver that will be notified of new connections.</param> /// <returns>A Listener.</returns> public static Listener StartListening(int aPort, LogSocketReaderReceiver aReceiver) { return new Listener( aPort, aReceiver); }