Proper way to stop TcpListener

These are two quick fixes you can use, given the code and what I presume is your design: 1. Thread.Abort() If you have started this TcpListener thread from another, you can simply call Abort() on the thread, which will cause a ThreadAbortException within the blocking call and walk up the stack. 2. TcpListener.Pending() The second … Read more

How many socket connections can a web server handle?

In short: You should be able to achieve in the order of millions of simultaneous active TCP connections and by extension HTTP request(s). This tells you the maximum performance you can expect with the right platform with the right configuration. Today, I was worried whether IIS with ASP.NET would support in the order of 100 … Read more

What is the async/await equivalent of a ThreadPool server?

I’d let the Framework manage the threading and wouldn’t create any extra threads, unless profiling tests suggest I might need to. Especially, if the calls inside HandleConnectionAsync are mostly IO-bound. Anyway, if you like to release the calling thread (the dispatcher) at the beginning of HandleConnectionAsync, there’s a very easy solution. You can jump on … Read more