I’m experimenting with the C# async CTP library and a socket server. I’m trying to listen for connections using the extension method AcceptTcpClientAsync which is added onto the System.Net.Sockets.TcpListener class. My code looks like this:
...
TcpListener listener = new TcpListener(IPAddress.Any, ServerPort);
listener.Start();
while (_active)
{
TcpClient client = await listener.AcceptTcpClientAsync();
AddConnection(client);
}
listener.Stop();
...
However, if I put a breakpoint at AddConnection it is never hit. Am I using this correctly?
That looks fine to me – you should get to the break point only when something tries to actually connect. Sounds like a silly question but – is anything connecting? If so, what happens when it tries?