Skip to content

doesn't close socket #19

Description

@erde-hoon

HttpServer.Dispose(); is not working properly

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

Activity

  1. shanielh commented on Nov 27, 2017

    @shanielh

    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.

  2. shanielh commented on Nov 27, 2017

    @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.

  3. gavazquez commented on Apr 25, 2018

    @gavazquez

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

  4. Psilax commented on Apr 25, 2019

    @Psilax

    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

  5. smaudet commented on Feb 25, 2024

    @smaudet

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions