//
// GCDAsyncSocket.h
//
// This class is in the public domain.
// Originally created by Robbie Hanson in Q3 2010.
// Updated and maintained by Deusty LLC and the Apple development community.
//
// https://github.com/robbiehanson/CocoaAsyncSocket
//
#import <Foundation/Foundation.h>
#import <Security/Security.h>
#import <Security/SecureTransport.h>
#import <dispatch/dispatch.h>
#import <Availability.h>
#include <sys/socket.h> // AF_INET, AF_INET6
@class GCDAsyncReadPacket;
@class GCDAsyncWritePacket;
@class GCDAsyncSocketPreBuffer;
extern NSString *const GCDAsyncSocketException;
extern NSString *const GCDAsyncSocketErrorDomain;
extern NSString *const GCDAsyncSocketQueueName;
extern NSString *const GCDAsyncSocketThreadName;
extern NSString *const GCDAsyncSocketManuallyEvaluateTrust;
#if TARGET_OS_IPHONE
extern NSString *const GCDAsyncSocketUseCFStreamForTLS;
#endif
#define GCDAsyncSocketSSLPeerName (NSString *)kCFStreamSSLPeerName
#define GCDAsyncSocketSSLCertificates (NSString *)kCFStreamSSLCertificates
#define GCDAsyncSocketSSLIsServer (NSString *)kCFStreamSSLIsServer
extern NSString *const GCDAsyncSocketSSLPeerID;
extern NSString *const GCDAsyncSocketSSLProtocolVersionMin;
extern NSString *const GCDAsyncSocketSSLProtocolVersionMax;
extern NSString *const GCDAsyncSocketSSLSessionOptionFalseStart;
extern NSString *const GCDAsyncSocketSSLSessionOptionSendOneByteRecord;
extern NSString *const GCDAsyncSocketSSLCipherSuites;
#if !TARGET_OS_IPHONE
extern NSString *const GCDAsyncSocketSSLDiffieHellmanParameters;
#endif
#define GCDAsyncSocketLoggingContext 65535
typedef NS_ENUM(NSInteger, GCDAsyncSocketError) {
GCDAsyncSocketNoError = 0, // Never used
GCDAsyncSocketBadConfigError, // Invalid configuration
GCDAsyncSocketBadParamError, // Invalid parameter was passed
GCDAsyncSocketConnectTimeoutError, // A connect operation timed out
GCDAsyncSocketReadTimeoutError, // A read operation timed out
GCDAsyncSocketWriteTimeoutError, // A write operation timed out
GCDAsyncSocketReadMaxedOutError, // Reached set maxLength without completing
GCDAsyncSocketClosedError, // The remote peer closed the connection
GCDAsyncSocketOtherError, // Description provided in userInfo
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@interface GCDAsyncSocket : NSObject
/**
* GCDAsyncSocket uses the standard delegate paradigm,
* but executes all delegate callbacks on a given delegate dispatch queue.
* This allows for maximum concurrency, while at the same time providing easy thread safety.
*
* You MUST set a delegate AND delegate dispatch queue before attempting to
* use the socket, or you will get an error.
*
* The socket queue is optional.
* If you pass NULL, GCDAsyncSocket will automatically create it's own socket queue.
* If you choose to provide a socket queue, the socket queue must not be a concurrent queue.
* If you choose to provide a socket queue, and the socket queue has a configured target queue,
* then please see the discussion for the method markSocketQueueTargetQueue.
*
* The delegate queue and socket queue can optionally be the same.
**/
- (id)init;
- (id)initWithSocketQueue:(dispatch_queue_t)sq;
- (id)initWithDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)dq;
- (id)initWithDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)dq socketQueue:(dispatch_queue_t)sq;
#pragma mark Configuration
@property (atomic, weak, readwrite) id delegate;
#if OS_OBJECT_USE_OBJC
@property (atomic, strong, readwrite) dispatch_queue_t delegateQueue;
#else
@property (atomic, assign, readwrite) dispatch_queue_t delegateQueue;
#endif
- (void)getDelegate:(id *)delegatePtr delegateQueue:(dispatch_queue_t *)delegateQueuePtr;
- (void)setDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
/**
* If you are setting the delegate to nil within the delegate's dealloc method,
* you may need to use the synchronous versions below.
**/
- (void)synchronouslySetDelegate:(id)delegate;
- (void)synchronouslySetDelegateQueue:(dispatch_queue_t)delegateQueue;
- (void)synchronouslySetDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
/**
* By default, both IPv4 and IPv6 are enabled.
*
* For accepting incoming connections, this means GCDAsyncSocket automatically supports both protocols,
* and can simulataneously accept incoming connections on either protocol.
*
* For outgoing connections, this means GCDAsyncSocket can connect to remote hosts running either protocol.
* If a DNS lookup returns only IPv4 results, GCDAsyncSocket will automatically use IPv4.
* If a DNS lookup returns only IPv6 results, GCDAsyncSocket will automatically use IPv6.
* If a DNS lookup returns both IPv4 and IPv6 results, the preferred protocol will be chosen.
* By default, the preferred protocol is IPv4, but may be configured as desired.
**/
@property (atomic, assign, readwrite, getter=isIPv4Enabled) BOOL IPv4Enabled;
@property (atomic, assign, readwrite, getter=isIPv6Enabled) BOOL IPv6Enabled;
@property (atomic, assign, readwrite, getter=isIPv4PreferredOverIPv6) BOOL IPv4PreferredOverIPv6;
/**
* User data allows you to associate arbitrary information with the socket.
* This data is not used internally by socket in any way.
**/
@property (atomic, strong, readwrite) id userData;
#pragma mark Accepting
/**
* Tells the socket to begin listening and accepting connections on the given port.
* When a connection is accepted, a new instance of GCDAsyncSocket will be spawned to handle it,
* and the socket:didAcceptNewSocket: delegate method will be invoked.
*
* The socket will listen on all available interfaces (e.g. wifi, ethernet, etc)
**/
- (BOOL)acceptOnPort:(uint16_t)port error:(NSError **)errPtr;
/**
* This method is the same as acceptOnPort:error: with the
* additional option of specifying which interface to listen on.
*
* For example, you could specify that the socket should only accept connections over ethernet,
* and not other interfaces such as wifi.
*
* The interface may be specified by name (e.g. "en1" or "lo0") or by IP address (e.g. "192.168.4.34").
* You may also use the special strings "localhost" or "loopback" to specify that
* the socket only accept connections from the local machine.
*
* You can see the list of interfaces via the command line utility "ifconfig",
* or programmatically via the getifaddrs() function.
*
* To accept connections on any interface pass nil, or simply use the acceptOnPort:error: method.
**/
- (BOOL)acceptOnInterface:(NSString *)interface port:(uint16_t)port error:(NSError **)errPtr;
#pragma mark Connecting
/**
* Connects to the given host and port.
*
* This method invokes connectToHost:onPort:viaInterface:withTimeout:error:
* and uses the default interface, and no timeout.
**/
- (BOOL)connectToHost:(NSString *)host onPort:(uint16_t)port error:(NSError **)errPtr;
/**
* Connects to the given host and port with an optional timeout.
*
* This method invokes connectToHost:onPort:viaInterface:withTimeout:error: and uses the default interface.
**/
- (BOOL)connectToHost:(NSString *)host
onPort:(uint16_t)port
withTimeout:(NSTimeInterval)timeout
error:(NSError **)errPtr;
/**
* Connects to the given host & port, via the optional interface, with an optional timeout.
*
* The host may be a domain name (e.g. "deusty.com") or an IP address string (e.g. "192.168.0.2").
* The host may also be the special strings "localhost" or "loopback" to specify connecting
* to a service on the local machine.
*
* The interface may be a name (e.g. "en1" or "lo0") or the corresponding IP address (e.g. "192.168.4.35").
* The interface may also be used to specify t
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
iOS即时通讯视频教学 (1034个子文件)
0080a3a5fd410770bce1a03e93cf4818a92ccb 96B
0080a3a5fd410770bce1a03e93cf4818a92ccb 96B
0080a3a5fd410770bce1a03e93cf4818a92ccb 96B
0080a3a5fd410770bce1a03e93cf4818a92ccb 96B
0080a3a5fd410770bce1a03e93cf4818a92ccb 96B
12f9d76b5fbbc7a42fecd973df23d39d3c367e 723B
12f9d76b5fbbc7a42fecd973df23d39d3c367e 723B
12f9d76b5fbbc7a42fecd973df23d39d3c367e 723B
12f9d76b5fbbc7a42fecd973df23d39d3c367e 723B
12f9d76b5fbbc7a42fecd973df23d39d3c367e 723B
14ec4395268259fbbd5fae3078ef822dd50262 929B
14ec4395268259fbbd5fae3078ef822dd50262 929B
14ec4395268259fbbd5fae3078ef822dd50262 929B
14ec4395268259fbbd5fae3078ef822dd50262 929B
14ec4395268259fbbd5fae3078ef822dd50262 929B
17f3c830f677a9804fe7183bb0da5fdab015d1 2KB
1d16d1e930f7423586bba391aec7fd0eabb079 115B
1d16d1e930f7423586bba391aec7fd0eabb079 115B
1d16d1e930f7423586bba391aec7fd0eabb079 115B
1d16d1e930f7423586bba391aec7fd0eabb079 115B
1d16d1e930f7423586bba391aec7fd0eabb079 115B
2d526db28d0d0655672af1ade5c7ca78173973 115B
2d526db28d0d0655672af1ade5c7ca78173973 115B
2d526db28d0d0655672af1ade5c7ca78173973 115B
2d526db28d0d0655672af1ade5c7ca78173973 115B
31076f83bf46a80d36ccf7f8b927e2b6da45f9 93B
31076f83bf46a80d36ccf7f8b927e2b6da45f9 93B
31076f83bf46a80d36ccf7f8b927e2b6da45f9 93B
31076f83bf46a80d36ccf7f8b927e2b6da45f9 93B
31076f83bf46a80d36ccf7f8b927e2b6da45f9 93B
3208e0c62b15c2c827eef16ff067f7a6cf2088 237B
3208e0c62b15c2c827eef16ff067f7a6cf2088 237B
3208e0c62b15c2c827eef16ff067f7a6cf2088 237B
3208e0c62b15c2c827eef16ff067f7a6cf2088 237B
3208e0c62b15c2c827eef16ff067f7a6cf2088 237B
3872be3917a99419c4c6a98860c44f1a277e83 115B
3872be3917a99419c4c6a98860c44f1a277e83 115B
388819c7f44a0b53e2a361a5a626c42d973d3d 174B
388819c7f44a0b53e2a361a5a626c42d973d3d 174B
3c7c1a0cda731237c1c3f843492611266da03d 289B
3c7c1a0cda731237c1c3f843492611266da03d 289B
3c7c1a0cda731237c1c3f843492611266da03d 289B
3c7c1a0cda731237c1c3f843492611266da03d 289B
3c7c1a0cda731237c1c3f843492611266da03d 289B
3e0f7e683541066a8629c0f2e182c263786501 288B
3e0f7e683541066a8629c0f2e182c263786501 288B
3e0f7e683541066a8629c0f2e182c263786501 288B
3e0f7e683541066a8629c0f2e182c263786501 288B
466ced77840996f2fc8259c0935828c5d4c5c2 274B
466ced77840996f2fc8259c0935828c5d4c5c2 274B
466ced77840996f2fc8259c0935828c5d4c5c2 274B
466ced77840996f2fc8259c0935828c5d4c5c2 274B
466ced77840996f2fc8259c0935828c5d4c5c2 274B
58a6bb02ea9eca59af9144be1e7cc8abe562ef 673B
58a6bb02ea9eca59af9144be1e7cc8abe562ef 673B
5f18d7a1ceac21d0ddc9996d4347eb1f372dd3 1KB
5f18d7a1ceac21d0ddc9996d4347eb1f372dd3 1KB
6419e8c563c7d5a463cf00acac60885b91ee22 384B
6419e8c563c7d5a463cf00acac60885b91ee22 384B
6419e8c563c7d5a463cf00acac60885b91ee22 384B
6660e59127268c49c8d626f9c19fc5b1e81b4a 194B
6660e59127268c49c8d626f9c19fc5b1e81b4a 194B
6660e59127268c49c8d626f9c19fc5b1e81b4a 194B
6660e59127268c49c8d626f9c19fc5b1e81b4a 194B
6a5456720bb687ce42b1b3ca6084179ed59d5b 187B
6a5456720bb687ce42b1b3ca6084179ed59d5b 187B
6a5456720bb687ce42b1b3ca6084179ed59d5b 187B
6a5456720bb687ce42b1b3ca6084179ed59d5b 187B
6a5456720bb687ce42b1b3ca6084179ed59d5b 187B
71c1cb7e4ef62829d2306069dcba359760ca13 203B
72de99ca4d3c2a6ddbefb54fb42dd4206a0fb9 97B
72de99ca4d3c2a6ddbefb54fb42dd4206a0fb9 97B
72de99ca4d3c2a6ddbefb54fb42dd4206a0fb9 97B
7afa5d0a83d8856f71a53d55e08ce1ddbf022a 385B
7afa5d0a83d8856f71a53d55e08ce1ddbf022a 385B
7d23e7b6a0a6d22983e15589441926e4ff0e5b 3KB
7d23e7b6a0a6d22983e15589441926e4ff0e5b 3KB
7d23e7b6a0a6d22983e15589441926e4ff0e5b 3KB
7d23e7b6a0a6d22983e15589441926e4ff0e5b 3KB
7d23e7b6a0a6d22983e15589441926e4ff0e5b 3KB
8992a4b74ae0d93da5fab1ec981a20e462056d 516B
8992a4b74ae0d93da5fab1ec981a20e462056d 516B
8992a4b74ae0d93da5fab1ec981a20e462056d 516B
8af836ce71367339aac037140e1370ede0a460 135B
8af836ce71367339aac037140e1370ede0a460 135B
8af836ce71367339aac037140e1370ede0a460 135B
8af836ce71367339aac037140e1370ede0a460 135B
8af836ce71367339aac037140e1370ede0a460 135B
8c98f7461bf98b2bc7e061150d8021121ad277 161B
8c98f7461bf98b2bc7e061150d8021121ad277 161B
8c98f7461bf98b2bc7e061150d8021121ad277 161B
8c98f7461bf98b2bc7e061150d8021121ad277 161B
8c98f7461bf98b2bc7e061150d8021121ad277 161B
8dc1d1aa431abc6dfa27a83a18beec06fa20db 1KB
917b3e51ff72699b5639eacbdbbf0acadfd9da 2KB
924d4e94958a164a59ad4740a6ab549e20bf3e 99B
924d4e94958a164a59ad4740a6ab549e20bf3e 99B
924d4e94958a164a59ad4740a6ab549e20bf3e 99B
924d4e94958a164a59ad4740a6ab549e20bf3e 99B
924d4e94958a164a59ad4740a6ab549e20bf3e 99B
共 1034 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
qq_40237381
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功