Skip to content

Use swift-native "SocketAddress" facilities #3448

@MahdiBM

Description

@MahdiBM

I'd assume the NIO team is interested in using (or merging) a library like swift-endpoint instead of accessing the platform C APIs.
I've heard from NIO maintainers that they don't like how the current SocketAddress leaks some C APIs.

This could either wait for the next major NIO version, or we could deprecate some of the current APIs in favor of those in swift-endpoint.

The advantages for using swift-endpoint would be:

  • No behavior discrepancies across platforms.
    • See this comment in AHC as an example of why that matters.
  • Better performance compared to using the C APIs.
    • See this section of the swift-endpoint README for more info.
  • All in Swift.
    • No need to expose or interact with C APIs.

I can't really think of any disadvantages, but I'm all ears if you know of something that would degrade if you were to use swift-endpoint.
One issue is swift-endpoint currently relies on ByteBuffer for the DomainName implementation so we'll need to make sure that doesn't result in a circular dependency.
Another issue is that I Just went with requiring Swift 6.2, which is a requirement that could be lowered although might take some library downgrades, since the library uses "the latest and greatest" like the new Span APIs (including some parts that were not back-deployed).

The library is also well-tested and well-benchmarked.
I'm open to discussions if you think something would need to change if NIO were to adopt this library.

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