July 2017
Beginner to intermediate
390 pages
10h 53m
English
We want to start a server listening for incoming connections on these IP addresses on port 8000. I want to do this in a separate thread so I can do other stuff in the main program while the server is waiting for something to connect in the background.
Replace the comment line //. The next code will appear here, with the following code:
var listener = new
TcpListener(IPAddress.Any, portNumber);
var connectionHandler = new ConnectionHandler();
var workerThread =
new Thread(connectionHandler.HandleConnections);
workerThread.Start(listener);
while (!Console.KeyAvailable) { }
Console.WriteLine("Shutting down");
listener.Stop();
workerThread.Abort();
This will not compile yet, as we are still missing ...
Read now
Unlock full access