Latest 0.0.1
Homepage https://github.com/longxdragon/DDTCPClient
License MIT
Platforms ios 8.0, requires ARC
Dependencies CocoaAsyncSocket, Reachability
Frameworks Foundation
Authors

DDTCPClient is a high level socket util based on CocoaAsyncSocket.

Features

  • Thread safety, socket operations is on serial queue.
  • Subcontracting and Sticky bag.
  • Maintain read package one.
  • Network state monitoring and reconnection mechanism.
  • Heartbeat mechanism.

Installation

CocoaPods

  1. Add pod 'DDTCPClient' to your Podfile.
  2. Run pod install or pod update.
  3. Import <DDTCPClient/DDTCPClient.h>.

Manually

  1. Download all the files in the Source subdirectory.
  2. Add the source files to your Xcode project.
  3. Import DDTCPClient.h.

Usage

Initialization

DDTCPClient *socket = [[DDTCPClient alloc] init];
socket.delegate = self;

Connect and disconnect

// Connect
[socket connectHost:host port:port];

// Disconnect
[socket disConnect];

Sent heart or send data

// Send data
NSString *registStr = @"I'm register informations";
NSData *registData = [registStr dataUsingEncoding:NSUTF8StringEncoding];

[socket sendData:registData];

// Sent heart, just set once, heart data will be send one by one
NSString *heartStr = @"I'm heart informations";
NSData *heartData = [heartStr dataUsingEncoding:NSUTF8StringEncoding];

[socket setHeartData:heartData];

Requirements

This library requires iOS 8.0+.

License

DDTCPClient is provided under the MIT license. See LICENSE file for details.

Latest podspec

{
    "name": "DDTCPClient",
    "version": "0.0.1",
    "summary": "A client of socket",
    "homepage": "https://github.com/longxdragon/DDTCPClient",
    "license": "MIT",
    "authors": {
        "longxdragon": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/longxdragon/DDTCPClient.git",
        "tag": "0.0.1"
    },
    "source_files": "Source/DDTCPClient/*.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": true,
    "dependencies": {
        "CocoaAsyncSocket": [
            "~> 7.6.2"
        ],
        "Reachability": []
    }
}

Pin It on Pinterest

Share This