mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
* NIO: Add new `BSDSocket` namespace This starts the split of the POSIX/Linux/Darwin/BSD interfaces and the BSD Socket interfaces in order to support Windows. The constants on Windows are not part of the C standard library and need to be explicitly prefixed. Use the import by name to avoid the `#if` conditions on the wrapped versions. This will allow us to cleanly cleave the dependency on the underlying C library. This change adds a `BSDSocket.OptionLevel` and `BSDSocket.Option` types which allow us to get proper enumerations for these values and pipe them throughout the NIO codebase. * Apply suggestions from code review Co-Authored-By: Cory Benfield <lukasa@apple.com>
NIOWebSocketClient
This sample application provides a simple WebSocket client. First it performs an upgrade from a HTTP connection. Once upgraded, it sends a 'ping' frame, with a body, to the server. It then checks that the body matches in the returning 'pong' frame. It also prints out any text frame received from the server. Invoke it using one of the following syntaxes:
swift run NIOWebSocketClient # Connects to a server on ::1, port 8888.
swift run NIOWebSocketClient 9899 # Connects to a server on ::1, port 9899
swift run NIOWebSocketClient /path/to/unix/socket # Connects to a server using the given UNIX socket
swift run NIOWebSocketClient echo.example.com 9899 # Connects to a server on echo.example.com:9899