Windows πŸ’ NIO

Hello NIO Users,

No, this is NOT an April Fool's prank!

As the Windows support has matured, large portions of the Swift ecosystem has become available on Windows. swift-nio provides a wonderful abstraction of the networking APIs and helpers for asynchronous programming that make writing efficient networking programs possible. Since networking is such a common operation these days, it makes sense that one would want to write networking code for their applications.

I'd like to announce that it is now possible to share your networking code written using swift-nio not only on Linux and macOS, but on Windows too! A simple example, here is a screenshot of the NIOEchoServer and NIOEchoClient from the swift-nio repository running on Windows (please ignore the unsightly debugging output):

The changes for this are on github in the swift-nio repository as a pull request, but the changes are not really in an organized state (it is a single ginormous patch) and there are a few places where the changes are not properly guarded. There is work that is needed to clean up the work and create more manageable changes which can be reviewed. Some of this will require a bit of work to adjust the APIs to abstract out details of the underlying system (e.g. there are cases where the underlying C library is expected to provide the BSD sockets API). However, this work demonstrates it is possible to provide the same API surface on all the platforms enabling cross-platform code.

Finally, thanks to @graskind, @lukasa, and @johannesweiss for helping answer in various states of confusion. Their answers helped make this possible.

May your packets flow freely,
Saleem

NB: for those interested in the patches: https://github.com/apple/swift-nio/pull/1405 is the current dump of my source tree.

CC: @tomerd @tkremenek

81 Likes

This is really fantastic work @compnerd! I know it's been a long road and many of the original design decisions in NIO made your life much harder than it needed to be, but you've done an amazing job pushing this far. We're looking forward to continuing to work with you to keep this moving forward andland this in NIO. Not to mention all of the possible exciting work in the form of an IOCP-based EventLoop!

8 Likes

Thanks @lukasa! Fortunately, I think that we should be able to address those design decisions and improve nio in the process!

One of the other cool things is that the new work also enables - the possibility of having NIO backed by alternate networking stacks - perhaps an option to back swift-nio by lwIP? :wink:

2 Likes

I think it'll be really great to see a new partner to swift-nio-transport-services in the "alternate networking backends". Especially as we move to a world envisioned in On the road to Swift 6 of Swift running in a wide range of environments, ensuring that NIO can run in those environments gives the Swift ecosystem enormous value. In particular I'm interested in environments further away from the traditional Unix space: while the various Windows options are one, I'm also keeping one eye on WASM as an environment too!

3 Likes

I want to echo everything @lukasa says, this is really fantastic work. Thank you!

I apologise for the POSIX/UNIX centric view of the world that SwiftNIO took, some things you have already fixed, some more we will fix, and when the time (it'll be a while I suspect) for NIO 3 has come we can iron out the vast majority of the wrinkles and delete a bunch of then-deprecated API :slight_smile:.

May your packets flow freely :rocket:

6 Likes

Awesome! I see that you are using Ninja, doesn't work via SPM yet?

Correct, unfortunately, swift-package-manager does not yet work on Windows.

This is so awesome!

Awesome!

Wow, awesome work @compnerd :tada: :-)

Slightly off-topic, what would it take to bring over SwiftPM, and where is work being done I can follow along in/help?

Also thank you so much for this, it's amazing news!! Do you happen to have a guide somewhere to make this work??

1 Like

There is an ongoing discussion of SwiftPM support on Windows in the "Portability of Swift Package Manager" topic.

3 Likes
Terms of Service

Privacy Policy

Cookie Policy