A collection of socket utilities in pure Swift
SwifterSockets is part of Swiftfire, the server for websites build with Swift.
- 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", from: <version-number>) ]
The must be replaced with the version number that must be used, for example: "0.11.0".
Use as a framework
First clone SwifterSockets and the create the Xcode project:
At the command line:
$ git clone https://github.com/Balancingrock/SwifterSockets $ cd SwifterSockets $ swift package generate-xcodeproj
Double click that project to open it. Once open set the
Defines Module to 'yes' in the
Build Settings before creating the framework. (Otherwise the import of the framework in another project 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.
- Migration to SPM 4
- Migration to Swift 4, minor adjustments.
- Upgraded BRUtils to 0.10.0
- Upgraded BRUtils to 0.9.0
- Upgraded BRUtils to 0.5.0
- Made incrementUsageCount and decrementUsageCount public.
- Bugfix: Closing a connection of a connection object could crash an application (rare, only observed once).
- Bugfix: There was a conditon that would prevent the release of connection objects causing a server to run out of connection objects (common when a server ran for several days without restarts)
- Updated the references captured by closures.
- In transmitterClosed the inerface is immediately set to 'nil' to prevent errors in an SSL connectionon closing.
- Renamed 'abortConnection' to 'connectionWasClosed'.
- Added sorting to the connection pool.
- Added closing of the socket on transmitterClosed.
- Added affectInactivityDetection parameter (default = true) to the transfer calls.
- Bugfix: The sQueue in SwifterSocket.Connection could be deallocated before its processes were complete.
- BRUtils update to 0.2.0
- Moved Result type to BRUtils
- Compile time improvement
- Added a result function to process Result results
- 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