doesn't close socket
HttpServer.Dispose(); is not working properly
Listening once, and Dispose it, and after that it cannot listening again on same port.
Dispose() is "eventually" disposing the socket (not waiting for the socket to close)
My suggestion is that you wouldn't re-create server instances in the same process, instead, you can change the logic of the server by creating a "Box" Handler and changing his underlying handler in run-time.
Actually, You're right, the IHTTPListener should implement IDisposable and allow you dispose the underlying _listener. But the server wouldn't do it for you.
I did a pull request for that as otherwise if you reload the dll you get this issue
This is not a bug of Dispose but of the socket implementations.
You have to add
tcpListener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
when setting up the tcp listener
Cross commenting but its worse than that, the ssl listener appears to do some unsafe stuff leaking clients and ssl ports...
I'm considering switching/re-writing the whole library, there's so much missing/wrong at this point. Its good if you just want to start a server, and write a lot of routing logic yourself.