void TcpEchoServerThreadMethod(string[] args)
{
//Check for correct amount of arguments.
int servPort = (args.Length >= 1) ? Int32.Parse(args[0]) : 7;
//Create a TcpListener Socket to accept client connection requests
TcpListener listener = new TcpListener(IPAddress.Any, servPort);
//Log to --------------v
ILogger logger = new ConsoleLogger();
listener.Start();
//Run forever; accepting and spawning threads to service each connection
while (true)
{
try
{
Socket clntSock = listener.AcceptSocket();
EchoProtocol protocol = new EchoProtocol(clntSock, logger);
Thread thread = new Thread(new ThreadStart(protocol.handleClient));
thread.Start();
logger.writeEntry("Created and started Thread = " + thread.GetHashCode());
}
catch (System.IO.IOException e)
{
logger.writeEntry("Exception = " + e.Message);
}
}
}