uHttpSharp icon indicating copy to clipboard operation
uHttpSharp copied to clipboard

doesn't close socket

Open erde-hoon opened this issue 8 years ago • 5 comments

HttpServer.Dispose(); is not working properly

Listening once, and Dispose it, and after that it cannot listening again on same port.

erde-hoon avatar Nov 27 '17 06:11 erde-hoon

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.

shanielh avatar Nov 27 '17 06:11 shanielh

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.

shanielh avatar Nov 27 '17 07:11 shanielh

I did a pull request for that as otherwise if you reload the dll you get this issue

gavazquez avatar Apr 25 '18 10:04 gavazquez

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

Psilax avatar Apr 25 '19 07:04 Psilax

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.

smaudet avatar Feb 25 '24 21:02 smaudet