From f9f663082faa186c94985bd779951aea5586b146 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Mon, 10 Jul 2017 09:59:11 +0400 Subject: [PATCH] Added travis-ci && updated readme --- .swift-version | 1 + .travis.yml | 30 ++++++++++++++++++++++++++++++ README.md | 33 ++++++++++++++++++++++++++------- Socket.swift.podspec | 2 +- 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .swift-version create mode 100644 .travis.yml diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..8c50098 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.1 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..716dfae --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +language: generic +matrix: + include: + - os: linux + dist: trusty + sudo: required + install: eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)" + script: swift test + + - os: osx + osx_image: xcode8.3 + dist: trusty + sudo: required + env: ACTION=test PLATFORM=Mac DESTINATION='platform=OS X' + script: set -o pipefail && xcodebuild -scheme SocketSwift -destination "$DESTINATION" $ACTION | xcpretty + + - os: osx + osx_image: xcode8.3 + dist: trusty + sudo: required + env: ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 6S' + script: set -o pipefail && xcodebuild -scheme SocketSwift -destination "$DESTINATION" $ACTION | xcpretty + + - os: osx + osx_image: xcode8.3 + dist: trusty + sudo: required + env: ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 1080p' + script: set -o pipefail && xcodebuild -scheme SocketSwift -destination "$DESTINATION" $ACTION | xcpretty + diff --git a/README.md b/README.md index 29fd36c..f889e51 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,34 @@ -[![Platform](https://img.shields.io/cocoapods/p/Socket.swift.svg?style=flat)](https://github.com/BiAtoms/Socket.swift) +![Platform Linux](https://img.shields.io/badge/platform-Linux-green.svg) +[![Platform iOS macOS tvOS](https://img.shields.io/cocoapods/p/Socket.swift.svg?style=flat)](https://github.com/BiAtoms/Socket.swift) [![Cocoapods Compatible](https://img.shields.io/cocoapods/v/Socket.swift.svg)](https://cocoapods.org/pods/Socket.swift) +[![Build Status - Master](https://travis-ci.org/BiAtoms/Socket.swift.svg?branch=master)](https://travis-ci.org/BiAtoms/Socket.swift) # Socket.swift A POSIX socket wrapper written in swift. -## Requirements +## OS + +Works in linux, iOS, macOS and tvOS -- iOS 8.0+ -- Xcode 8.0+ -- Swift 3.0+ +## Example +```swift +let server = try Socket.tcpListening(port: 8090) //start socket listening at localhost:8090 + +let client = try Socket(.inet, type: .stream, protocol: .tcp) +try client.connect(port: 8090) //connecting to the socket at localhost:8090 +let clientAtServerside = try server.accept() + +let bytes = ([UInt8])("Hello World".utf8) +try clientAtServerside.write(bytes) //sening bytes to the client socket +clientAtServerside.close() + +while let byte = try? client.read() { //reading bytes sent by server socket + print(byte) +} +client.close() +server.close() +``` ## Installation @@ -26,7 +45,7 @@ To integrate Socket.swift into your Xcode project using CocoaPods, specify it in ```ruby source 'https://github.com/CocoaPods/Specs.git' target '' do - pod 'Socket.swift' ~> '1.0' + pod 'Socket.swift' ~> '1.3' end ``` @@ -36,7 +55,7 @@ Then, run the following command: $ pod install ``` ### Manually -Just drag and drop the [Sources/Socket.swift](Sources/Socket.swift) file. +Just drag and drop the files in the [Sources](Sources) folder. ## Authors diff --git a/Socket.swift.podspec b/Socket.swift.podspec index 1babd28..e8dd10e 100644 --- a/Socket.swift.podspec +++ b/Socket.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Socket.swift' - s.version = '1.1' + s.version = '1.3' s.summary = 'A POSIX socket wrapper written in swift.' s.homepage = 'https://github.com/BiAtoms/Socket.swift' s.license = { :type => 'MIT', :file => 'LICENSE' }