Latest 2.0.0
Homepage https://github.com/ruibox001/SFTcp
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

License MIT 
CocoaPods 
Build Status

iOSTcp连接库:

1、封装Tcp连接
2、自动重连
3、IPV6支持
4、实例导读


封装了Tcp请求类,使用方便,源码开放

@class SFTcpSocket;

#pragma mark - 代理定义
@protocol SFTcpSocketDelegate <NSObject>
@optional

#pragma mark - 代理收到数据回调
- (void)tcpSocket:(SFTcpSocket *)udpSocket receverData:(NSString *)data;

#pragma mark - 代理连接状态变化回调
- (void)tcpSocket:(SFTcpSocket *)udpSocket connectStatus:(BOOL)connect;

@end

@interface SFTcpSocket : NSObject

#pragma mark - 处理类
@property (nonatomic, strong) SocketBgAutoHandler *handle;

#pragma mark - tcp单利
+ (instancetype) shareTcpSocket;

#pragma mark - 连接到服务器
- (void)connect:(NSString *)host port:(int)port;

#pragma mark - 端开连接
- (void)disConnect;

#pragma mark - 是否正在连接
- (BOOL)isConnected;

#pragma mark - 重新连接
- (void)reConnect;

#pragma mark - 发送数据
- (void)sendData:(NSData *)data;
- (void)sendString:(NSString *)string;

#pragma mark - 添加代理
- (void)addDelegate:(id<SFTcpSocketDelegate>)delegate;

#pragma mark - 移除代理
- (void)removeDelegate:(id<SFTcpSocketDelegate>)delegate;

安装

CocoaPods

    1. 在 `Podfile` 中添加 `pod 'SFTcp'`
    2. 执行 `pod install` 或 `pod update`

手动安装

    1. 下载`SFTcp`文件夹内的所有内容。
    2. 将`SFTcp`内的源文件添加(拖放)到你的工程。

Latest podspec

{
    "name": "SFTcp",
    "version": "2.0.0",
    "authors": {
        "ruibox001": "[email protected]"
    },
    "homepage": "https://github.com/ruibox001/SFTcp",
    "summary": "SFTcp u662fu5c01u88c5u4e86Tcpu8bf7u6c42u7c7buff0cu4f7fu7528u65b9u4fbfuff0cu6e90u7801u5f00u653e",
    "source": {
        "git": "https://github.com/ruibox001/SFTcp.git",
        "tag": "v2.0.0"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "SFTcp",
    "public_header_files": "SFTcp/*.h",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This