开发者

async CTP AcceptTcpClientAsync method

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜