This issue is likely to arise when the Swift toolchain is 5.0 or lower. The implicit return statement that is used was introduced in Swift 5.1. You can fix this on lower versions of Swift by adding the return keyword yourself, or by upgrading the Swift version.
Hello and thank you very much for the great tutorial!
I have two questions on SwiftNIOâs (Vaporâs, respectively) capabilities, maybe you can help:
Am using the Network framework on my iOS App client for creating an NWConnection to my server with DTLS over UDP (I use init(dtls:udp:) for the NWParameters). I am hoping that I can write my server in Swift and I am really happy that you have all these awesome resources on the topic on server-side swift and Vapor. Thanks a lot for these!!!
So I need to be able to accept a DTLS over UDP connection on my server.
My understanding is that SwiftNIO provides a connection for UDP via DataGramBoostrap for a server.
My questions are the following:
How can I set the âdtls optionâ in SwiftNIO for my UDP server (when I use DataGramBootstrap)?
I understand that Vapor 4 does not yet provide UDP support, is that correct? So in any case I would have to work with the lower level SwiftNIO, is that correct? Is there a plan to include UDP support in Vapor 5?
Vapor 4 doesnât provide UDP support, but SwiftNIO does. As SwiftNIO forms much of the foundation for Vapor, I donât see any issues with using SwiftNIO based UDP servers. However, if you want to run this service on an iOS device, youâll quickly run into a lack of support inside with SwiftNIO.
SwiftNIO has a fundamental concept of a âchannelâ, which can be used as a transport for anything, usually ByteBuffer when it comes to networking. (Note the usually, since SwiftNIOâs UDP support doesnât use raw a ByteBuffer). These channels can by implemented by anyone, for many reasons. You could have a VPN implementation, and expose a VPN tunnel as a channel.
To expand upon the POSIX sockets for iOS, the NIO team created SwiftNIOTransportServices, which implements Network.Framework support for SwiftNIO. This build does not yet support UDP, but Iâve made a PR to address that. My PR is functional, but incomplete.
Alternatively, you could copy my UDP support from the PR and use that, but the PR you see unfortunately doesnât yet support UDP servers.
If you want to use the regular POSIX UDP sockets, you can use that. But Iâm not aware of the details of DTLS Support in SwiftNIOâs POSIX UDP services.