A collection of socket utilities in pure Swift
SwifterSockets is part of Swiftfire, the next generation personal webserver.
- Shields the Swift application from the complexity of the Unix socket calls.
- Directly interfaces with the POSIX calls using:
- Implements a framework on top of the POSIX calls with:
- Connection (class)
- connectToTipServer (returns a connection)
- TipServer (class, produces connections)
- Includes replacements for the FD_SET, FD_CLR, FD_ZERO and FD_ISSET macro’s.
- Builds as a library using the Swift Package Manager (SPM)
If you need secure connections, check out SecureSockets. SecureSockets is build on top of SwifterSockets (and OpenSSL).
The reference manual is hosted at Swiftfire.nl
SwifterSockets is distributed as a Swift package and as a framework.
Use as a SPM package
Extend the dependency of your project package with:
dependencies: [ ... .Package(url: "https://github.com/Balancingrock/SwifterSockets", <version-number>) ]
Use as a framework
First clone SwifterSockets:
At the command line:
$ git clone https://github.com/Balancingrock/SwifterSockets $
This creates a subdirectory called SwifterSockets.
In this subdirectory you will find an xcode project. Double click that project to open it. Once open, build the project. This will create a SwifterSockets.framework.
If -for whatever reason- you have to regenerate the xcode project ($ swift package generate-xcodeproj) then be sure to set the
Defines Module to ‘yes’ in the
Build Settings before creating the framework. (Otherwise the import of the framework in another project -as described below- won’t work)
In the project that will use SwifterSockets, add the SwifterSockets.framework by opening the
General settings of the target and add the SwifterSockets.framework to the
In the Swift source code import SwifterSockets by
import SwifterSockets at the top of the file.
Note: Planned releases are for information only, they are subject to change without notice.
- No new features planned. Features and bugfixes will be made on an ad-hoc basis as needed to support Swiftfire development.
- For feature requests and bugfixes please contact firstname.lastname@example.org
- The current verion will be upgraded to 1.0.0 status when the full set necessary for Swiftfire 1.0.0 has been completed.
- Added inactivity detection for Connections.
- More access level updates
- Added buffer pointer to transfer protocol
- Added buffered transmissions to Connections
- Moved some protocols from the general area to specific files
- Added connection pool manager
- Re-evaluated open/public access
- Added logId fo the InterfaceAccess protocol
- Updated comments
- Improved documentation for reference manual generation
- Comment changes
- Added xcode project for framework generation
- Fixed some access control levels
- Major redesign to support SecureSockets the SSL complement to SwifterSockets. The old interfaces have changed and the thread related operations have been replaced by the new approach to use Connection objects rather than directly interfacing with the threads.
- Upgraded to Xcode 8 beta 6 (Swift 3)
- Upgraded to Xcode 8 beta 3 (swift 3)
- Fixed a bug where accepting an IPv6 connection would fill an IPv4 sockaddr structure.
- Added SocketAddress enum adopted from Marco Masser: http://blog.obdev.at/representing-socket-addresses-in-swift-using-enums
- Header update to include new website: swiftfire.nl
- Changed target to framework
- Made the necessary interfaces public
- Removed the dependency on SwifterLog to prevent cross-usage
- Added tags to mark releases
- Removed other not used files/directories
- Upgraded to Swift 2.2.
- Added closeSocket call.
- Added ‘logUnixSocketCalls’ (needs SwifterLog).
- Added note on buffer capture to transmitAsync:buffer.
- Added SERVER_CLOSED and CLIENT_CLOSED to TransmitResult.
- Changed DataEndDetector from a class to a protocol.
- Added SERVER_CLOSED to ReceiveResult.
- Replaced error numbers in the receiver functions with #file.#function.#line
- Added CLOSED AcceptResult.
- Fixed a bug that missed the error return from the select call in the accept functions.
- Changed type of object in ‘synchronized’ from AnyObject to NSObject
- Added EXC_BAD_INSTRUCTION info to fd_set
- TransmitTelemetry and ReceiveTelemetry now inherit from NSObject
- Replaced (UnsafePointer
, length) with UnsafeBufferPointer
- Added note on DataEndDetector that it can be used to receive the data also.
- Initial release