Latest 1.3
Homepage https://github.com/BiAtoms/Socket.swift
License MIT
Platforms ios 8.0, osx 10.9, tvos 9.0
Authors

Platform Linux
Platform iOS macOS tvOS
Cocoapods Compatible
Build Status - Master

A POSIX socket wrapper written in swift.

OS

Works in linux, iOS, macOS and tvOS

Example

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

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Socket.swift into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
target '<Your Target Name>' do
    pod 'Socket.swift' ~> '1.3'
end

Then, run the following command:

$ pod install

Manually

Just drag and drop the files in the Sources folder.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License – see the LICENSE file for details

Latest podspec

{
    "name": "Socket.swift",
    "version": "1.3",
    "summary": "A POSIX socket wrapper written in swift.",
    "homepage": "https://github.com/BiAtoms/Socket.swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Orkhan Alikhanov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/BiAtoms/Socket.swift.git",
        "tag": "1.3"
    },
    "module_name": "SocketSwift",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "tvos": "9.0"
    },
    "source_files": "Sources/*.swift",
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This