A log server for network logging

An implementation of a server application that can handle incoming streams of data from a remote application is given next. Here we are using System.Net's TCPListener class to listen to the incoming connection. Once we receive a connection from the remote process, we will kick-start a thread to handle the log data from that connection. This implementation is given here for the sake of completeness:

 class LogSocketServer { private TcpListener _server; private Boolean _running; private int port = 4500; public LogSocketServer() { _server = new TcpListener(IPAddress.Any, port); _server.Start(); _running = true; AcceptClients(); } public void AcceptClients() { while (_running) { TcpClient newClient = _server.AcceptTcpClient(); ...

Get .NET Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.