Skip to content

Property to see the status of the server connection #83

Closed

Description

@krjaction50

We've had some network errors where the server-side socket gets closed in our windows service. We have a background that does a lot of housekeeping. I was looking for a property on TcpHost to give me the status of the underlying connection. (open, closed, error, etc). I do not see such a property exposed. This would allow me to keep trying to re-open the server-side connection if it errors out.

Activity

  1. tylerje commented on Nov 3, 2023

    @tylerje
    Member

    You're welcome to submit a PR that does that. My time for maintenance of late has been rather limited.

  2. tylerje commented on Jan 11, 2024

    @tylerje
    Member

    If time allows, I'll be exploring this as an enhancement.

  3. krjaction50 commented on Jan 11, 2024

    @krjaction50
    Author

    yeah I just don't have time to do it. It should be very simple from looking at the code. Rarely, we get a disconnect on the server-side and we have no way to recover from that because we have no way to know it happened. We have a background housekeeping thread that runs ever 5 seconds where I could check and if it's disconnected spin up a new server listener.

    Thanks

  4. tylerje commented on Jan 11, 2024

    @tylerje
    Member

    Simple perhaps to give you the status from the host side, but more complex to recover or know this from the client side. One could, if the connection is exposed, even read only, test the state on the host side and re-open the host listener. OR we might be able to have that automatically done using a flag and have the library open a new host/listener if for some reason it has been killed.

  5. krjaction50 commented on Jan 11, 2024

    @krjaction50
    Author

    This would be a server-side thing only. The client just will error out since the server is no longer listening. We just need a public property on the server-side class that shows the status of the connection/socket.

  6. tylerje commented on Aug 18, 2026

    @tylerje
    Member

    Implemented for 6.0.1. TcpHost and NpHost now inherit a public Host.Status property. Its HostStatus values are Created, Opening, Open, Faulted, and Closed; listener failures transition the host to Faulted. This reports host-listener lifecycle rather than an individual client connection. Added regression coverage for normal open/close transitions and TCP bind failures on .NET 10 and .NET Framework 4.8.

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

      ⌂ 换网址