Skip to content

Commit

Permalink
Migration to SPM 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Rien committed Apr 9, 2018
1 parent 5cd3d15 commit ce134d7
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 13 deletions.
14 changes: 13 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// swift-tools-version:4.0

import PackageDescription

let package = Package(
name: "SwifterSockets",
products: [
.library(
name: "SwifterSockets", targets: ["SwifterSockets"])
],
dependencies: [
.Package(url: "https://github.com/Balancingrock/BRUtils", Version(0, 11, 0))
.package(url: "https://github.com/Balancingrock/BRUtils", from: "0.11.1")
],
targets: [
.target(
name: "SwifterSockets",
dependencies: ["BRUtils"]
)
]
)
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Extend the dependency of your project package with:

dependencies: [
...
.Package(url: "https://github.com/Balancingrock/SwifterSockets", <version-number>)
.package(url: "https://github.com/Balancingrock/SwifterSockets", from: <version-number>)
]

The _<version-number>_ must be replaced with the version number that must be used, for example: "0.2.0".
The _<version-number>_ must be replaced with the version number that must be used, for example: "0.11.0".

## Use as a framework

Expand Down Expand Up @@ -70,7 +70,11 @@ Note: Planned releases are for information only, they are subject to change with

- The current verion will be upgraded to 1.0.0 status when the full set necessary for Swiftfire 1.0.0 has been completed.

#### 0.10.11 (Current)
#### 0.11.0 (Current)

- Migration to SPM 4

#### 0.10.11

- Migration to Swift 4, minor adjustments.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions doc/User Manual.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#User Directions
# User Directions

For a good introduction into socket programming, see [Beej's Guide to Network Programming](http://beej.us/guide/bgnet/output/html/multipage/index.html).

For an introduction into socket programming in Swift, see my blog series [Socket Programming in Swift](http://swiftrien.blogspot.com/2015/10/socket-programming-in-swift-part-1.html)

This document will show how to use SwifterSockets for socket programming.

#Introduction
# Introduction

SwifterSockets can be used two ways: either as some syntactic sugar over the Unix socket calls, or as a abstraction layer over the Unix socket calls.

In the first case, socket programming is still socket programming. It will be necessary to gain some knowledge about socket programming via for example the Beej's guide.
In the first case, socket programming is still socket programming. It will be necessary to gain some knowledge about socket programming, for example the Beej's guide.

In the second case it is not necessary to learn about socket programming, but it is necessary to learn about SwifterSockets.

The following subsections are intended to get things goiing.

For installation, see the [README](https://github.com/Balancingrock/SwifterSockets/blob/master/README.md)

##Use as syntactic sugar
## Use as syntactic sugar

SwifterSockets provides the following functions for this kind of usage:

Expand Down Expand Up @@ -54,15 +54,15 @@ To setup a server, use `setupTipServer` followed by `tipAccept` and then `tipTra

Call `closeSocket` to terminate a connection from either client or server.

##Connection based usage
## Connection based usage

On a higher abstraction level SwifterSockets uses a "Connection" based approach. Whether as client or as server.

All _transmit_ and _receive_ operations take place on a Connection object.

For this purpose SwifterSockets contains a `Connection` class that can be used directly, but much more likely can be used as the basis for a subclass that implements the _transmit_ and _receive_ operations needed in a project.

###Connection Object Factory
### Connection Object Factory

Your project has to provide a connection object factory.

Expand All @@ -82,7 +82,7 @@ For SwifterSockets it always is an instance of `TipInterface`.

The second parameter `address` allows the connection factory to determine if the connection request should be granted and/or to create a log of clients or servers that have been connected.

###Setup a connection to a server
### Setup a connection to a server

To connect to a server use `connectToTipServer`:

Expand All @@ -103,7 +103,7 @@ public enum Result<T> {
```
The object that is returned can be used to transmit and receive data to and from the peer. When the connection is no longer needed, call `closeConnection`. If there is a connection pool, the child class should override `closeConnection` to put the object back into the (free) pool.

###Setup a server
### Setup a server

To setup a server, instantiate a new `TipServer` object. A server can have a lot of options, these are configured through an optional option list that can contain one or more of the following enums:

Expand Down Expand Up @@ -164,4 +164,4 @@ public enum Option {

Of course to be usefull, at least the connectionObjectFactory should be set.

When a connection is accepted and the connectionObjectFactory returned a connection object, the receiverloop of the connection object will be started automatically. Hence the connection object can immediately start servicing the incoming request without additional setup.
When a connection is accepted and the connectionObjectFactory returned a connection object, the receiverloop of the connection object will be started automatically. Hence the connection object can immediately start servicing the incoming request without additional setup.

0 comments on commit ce134d7

Please sign in to comment.