Example #1
0
            /// <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();
            }
Example #2
0
            /// <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();
            }
Example #3
0
 /// <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));
 }
Example #4
0
 /// <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));
 }
Example #5
0
 /// <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)
 {
 }
Example #6
0
            /// <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();
            }
Example #7
0
 /// <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)
 {
 }
Example #8
0
 /// <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);
 }
Example #9
0
 /// <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);
 }