The SwiftNIO team is thrilled to announce the release of NIOTransportServices. NIOTransportServices provides NIO users with a complete collection of EventLoop
s, EventLoopGroup
s, and Channel
s to help users use Network.framework with a SwiftNIO API.
The goal is that all currently existing SwiftNIO applications should run almost entirely unmodified using NIOTransportServices. The only changes required are to use a new EventLoopGroup
(NIOTSEventLoopGroup
), and new bootstraps to create your channels (NIOTSConnectionBootstrap
, NIOTSListenerBootstrap
). Once the Channel
s are created via the bootstraps, all currently existing NIO code should be able to behave exactly as though it is in a regular NIO channel. This means channel handlers and code that uses them can be completely re-used across regular NIO and NIOTransportServices.
Network.framework provides NIO with a number of powerful tools, including a richer connection lifecycle, access to a user-space TCP stack, and full support for operating on iOS and tvOS, including appropriate integration to the radios on mobile devices that is not possible with the socket
API. Additionally it enables powerful networking technologies not currently supported in the mainline of SwiftNIO, such as MPTCP. Finally, it provides first-class integration with Apple's platform TLS implementation, allowing users to avoid the burden of using OpenSSL or LibreSSL on Apple platforms.
Additionally, these event loops and channels use Dispatch
to manage their threading, instead of pthreads. This gives them support for maintaining and using QoS, helping your applications stay responsive and make efficient use of the hardware available to them.
There are a few limitations with NIOTransportServices that you ought to be aware of. Firstly, note that NIOTransportServices will only run on macOS Mojave, and iOS and tvOS 12. These operating systems are currently in beta. Note also that this means your applications will need a minimum deployment target appropriate for those operating systems to correctly compile when using NIOTransportServices. To provide this to Swift Package Manager, you need to pass the -Xswiftc -target -Xswiftc x86_64-apple-macosx10.14
(or equivalent) flags to any invocation of swift test
or swift build
.
Secondly, we do not currently support UDP with Network.framework. There are also some highly advanced Network.framework features that are not currently supported, such as TCP Fast Open. Support for these features will be added in future, and will be prioritised based on the interest and feedback of our users.
Finally, please note that for the moment NIOTransportServices is in beta, with a 0.x version number. We encourage you to play with NIOTransportServices and provide feedback, but we recommend pinning to specific versions where possible, as we reserve the right to break the APIs for a while. We will cut a 1.0 release sometime shortly after the full public release of the beta Apple platforms.
We really hope you love using NIOTransportServices. Please let us know if you have any feedback, or encounter any problems. Happy coding!