Swiftpack.co - Package - Balancingrock/SwifterSockets

SwifterSockets

A collection of socket utilities in pure Swift

SwifterSockets is part of the Swiftfire webserver project.

The Swiftfire website

The reference manual

SwifterSockets is also used in our PortSpy application in the App Store. Buyers of PortSpy get the complete sources of the project (Xcode project) used to build the App.

If you need secure connections, check out SecureSockets which is build on top of SwifterSockets (and OpenSSL).

If you are new to socket programming, check out our blog series which starts here

Features

  • Shields the Swift application from the complexity of the Unix socket calls.
  • Directly interfaces with the POSIX calls using:
    • connectToTipServer
    • tipTransfer
    • tipReceiverLoop
    • tipAccept
    • setupTipServer
  • 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)

Installation

SwifterSockets can be used by the Swift Package Manager. Just add it to your package manifest as a dependency.

Alternatively you can clone the project and generate a Xcode framework in the following way:

  1. First clone the repository and create a Xcode project:

     $ git clone https://github.com/Balancingrock/SwifterSockets
     $ cd SwifterSockets
     $ swift package generate-xcodeproj
    
  2. 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)

  3. 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 Embedded Binaries.

  4. In the Swift source code where you want to use it, import SwifterSockets at the top of the file.

Version history

No new features planned. Updates are made on an ad-hoc basis as needed to support Swiftfire development.

1.0.2

  • Documenation updates

1.0.1

  • Fixed website link in header

1.0.0

  • Restructured for Swiftfire 1.0.0

Github

link
Stars: 56

Dependencies

Used By

Total: 0

Releases

Release 1.0.0 - 2019-08-18 11:41:48

Swiftfire -and all its supporting packages- have been issued in their release 1.0.0

SwifterSockets has undergone some file-renaming and some reorganization. Otherwise the functionality itself is unchanged.

Migration to SPM 4 - 2018-04-09 06:55:42

Switched to Swift Package Manager 4

Migration to Swift 4 - 2018-04-05 18:57:39

Minor adjustments for Swift 4.

Dependency Update - 2018-03-31 08:33:24

BRUtils was updated to 0.10.0

Dependency update - 2017-11-25 15:15:31

BRUtils was updated to 0.9.0.

Minor updates to support Swiftfire - 2017-06-08 11:11:12

The BRUtils package has been upgraded to 0.5.0. In 'SwifterSockets.Connection.swift' the methods incrementUsageCount and decrementUsageCount have been made public. (To help in supporting very large HTTP bodies by Swiftfire).

Bugfix release - 2017-05-24 12:08:39

Two bugs were fixed:

  • A crash that would occur when a connection object received data just (milli seconds) before it was closed.
  • A bug that would cause connection objects to go missing when a connection was accepted, but no data was ever received. This was a fairly common occurrence and would result in a non-response server.

Unfortunately this necessitated the change of 1 interface in Connection.swift: 'receiverData' is now supplanted by 'processReceivedData'.

Minor bugfixes - 2017-05-02 17:28:09

Bugfixes:

  • Updated references captured by closures
  • In 'transmitterClosed' the interface is immediately nilled to prevent SSL errors on closing
  • Added closing of the socket on 'transmitterClosed'

Added functionality:

  • Sorting of connections in the connection pool

API changes:

  • Renamed 'abortConnection' to 'connectionWasClosed'

New feature - 2017-04-09 12:50:43

Added "affectInactivityDetection" parameters to Connection - transfer functions. This allows the transmission of data in the inactivity detection action itself. The parameter is by default set to "true" so no code updates are necessary.

Bugfix - 2017-04-09 06:17:27

The sQueue in SwifterSockets.Connection could be deallocated before its processes were finished.