Skip to content

Conversation

@dbernero
Copy link

Description

It occurred to me today that there did not exist an explicit function to determine the connectivity status of a TCP Client process. If a user or developer wanted to definitively close a socket without running the chance of generating an Error log, they would need to probe the struct returned by Tcp.Client.state/1, which felt improper.

This PR adds the public function Tcp.Client.connected?/1 which compartmentalizes that probing, allowing a user/developer to determine a simple true/false response as to whether or not the Client is currently connected to a Server. The function will return true if :socket is non-nil and :status is :connected, otherwise it will return false.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Simple local tests with TCP Client/Server
  • Unit Test included and passing

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@dbernero dbernero force-pushed the expose-tcp-connected-status branch from 4158fd9 to 5e2abe5 Compare October 16, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant