Latest 0.2
License MIT
Platforms ios 10.0

A wrapped Swift toolkit for socket connection


  • Xcode 8.0+
  • iOS 10.0+
  • Swift 3.0+


SocketKit can be installed through Cocoapods or manual import.


$ gem install cocoapods

After installation of cocoapods, create a file named Podfile at the root directory of the project:

For swift3:

source ''
platform :ios, '10.0'

target '<Your Target Name>' do
    pod 'SocketKit'

Then, run the following command:

$ pod install

User Manual:

Kit imports

import SocketKit


The only class will be used in the kit. All the requests go from this kit.


public init(address: String, port: Int) throws { ... }

SocketError.connectionFailed may be thrown from the constructor when connection failed

Read from socket

public func read(complete: @escaping (String?) -> Void) throws { ... }

This function accepts a call back closure, which will be called when value is read from socket server side
The closure accepts an optional string, and may throw out a SocketError.notConnected if the socket lost connection

Write to socket

public func write(value: String) throws { ... }

This function accepts an UTF-8 string value, and encode the string to binary data, then write to the socket server.
SocketError.notConnected may be thrown if the socket connection is lost
SocketError.notWritable may be thrown if the socket is not allowed to write values
SocketError.dataEncodingFailed may be thrown if the string value cannot be encoded

Connection status

public var isConnected: Bool

This attribute returns true if the socket is connected, otherwise false


WeatherKit is released under the MIT license. See LICENSE for details.

Latest podspec

    "name": "SocketKit",
    "version": "0.2",
    "summary": "A wrapped Swift toolkit for socket connection",
    "description": "A wrapped Swift toolkit for socket connection with simplified IO functions.nEasy to use and create.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Yaxin Cheng": "[email protected]"
    "platforms": {
        "ios": "10.0"
    "source": {
        "git": "",
        "tag": "0.2"
    "source_files": [

Pin It on Pinterest

Share This