//
// 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;
@protocol GCDAsyncSocketDelegate;
NS_ASSUME_NONNULL_BEGIN
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.
**/
- (instancetype)init;
- (instancetype)initWithSocketQueue:(nullable dispatch_queue_t)sq;
- (instancetype)initWithDelegate:(nullable id<GCDAsyncSocketDelegate>)aDelegate delegateQueue:(nullable dispatch_queue_t)dq;
- (instancetype)initWithDelegate:(nullable id<GCDAsyncSocketDelegate>)aDelegate delegateQueue:(nullable dispatch_queue_t)dq socketQueue:(nullable dispatch_queue_t)sq;
#pragma mark Configuration
@property (atomic, weak, readwrite, nullable) id<GCDAsyncSocketDelegate> delegate;
#if OS_OBJECT_USE_OBJC
@property (atomic, strong, readwrite, nullable) dispatch_queue_t delegateQueue;
#else
@property (atomic, assign, readwrite, nullable) dispatch_queue_t delegateQueue;
#endif
- (void)getDelegate:(id<GCDAsyncSocketDelegate> __nullable * __nullable)delegatePtr delegateQueue:(dispatch_queue_t __nullable * __nullable)delegateQueuePtr;
- (void)setDelegate:(nullable id<GCDAsyncSocketDelegate>)delegate delegateQueue:(nullable 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:(nullable id<GCDAsyncSocketDelegate>)delegate;
- (void)synchronouslySetDelegateQueue:(nullable dispatch_queue_t)delegateQueue;
- (void)synchronouslySetDelegate:(nullable id<GCDAsyncSocketDelegate>)delegate delegateQueue:(nullable 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;
/**
* When connecting to both IPv4 and IPv6 using Happy Eyeballs (RFC 6555) https://tools.ietf.org/html/rfc6555
* this is the delay between connecting to the preferred protocol and the fallback protocol.
*
* Defaults to 300ms.
**/
@property (atomic, assign, readwrite) NSTimeInterval alternateAddressDelay;
/**
* 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, nullable) 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:(nullable NSString *)interface port:(uint16_t)port error:(NSError **)errPtr;
/**
* Tells the socket to begin listening and accepting connections on the unix domain at the given url.
* 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, ethe
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
SocketDemo.zip (85个子文件)
SocketDemo
SocketControl
.DS_Store 6KB
Socket.h 1KB
SocketModel.h 204B
DataControl.m 3KB
Socket.m 5KB
ReconnectControl.h 575B
PrefixHeader.pch 296B
SocketModel.m 188B
DataControl.h 389B
ReconnectControl.m 2KB
.DS_Store 6KB
Utils
.DS_Store 6KB
MJExtension
MJProperty.m 5KB
NSObject+MJCoding.m 2KB
MJFoundation.h 259B
MJPropertyKey.m 648B
NSString+MJExtension.h 1KB
NSObject+MJProperty.h 3KB
MJPropertyKey.h 680B
MJPropertyType.m 2KB
MJProperty.h 2KB
MJExtension.h 517B
MJExtensionConst.h 2KB
NSObject+MJClass.h 3KB
NSObject+MJProperty.m 10KB
NSObject+MJClass.m 5KB
MJPropertyType.h 1KB
MJExtensionConst.m 885B
NSObject+MJCoding.h 1KB
NSObject+MJKeyValue.h 10KB
MJFoundation.m 1KB
NSObject+MJKeyValue.m 25KB
NSString+MJExtension.m 3KB
AFNetworking
AFURLSessionManager.h 29KB
AFSecurityPolicy.h 6KB
AFSecurityPolicy.m 13KB
AFNetworking.h 2KB
AFNetworkReachabilityManager.h 8KB
AFURLResponseSerialization.h 12KB
AFNetworkReachabilityManager.m 10KB
UIKit+AFNetworking
UIProgressView+AFNetworking.h 2KB
UIActivityIndicatorView+AFNetworking.m 5KB
UIKit+AFNetworking.h 2KB
AFImageDownloader.m 17KB
UIImageView+AFNetworking.m 6KB
UIImage+AFNetworking.h 1KB
UIActivityIndicatorView+AFNetworking.h 2KB
AFNetworkActivityIndicatorManager.m 10KB
AFImageDownloader.h 9KB
UIProgressView+AFNetworking.m 5KB
UIRefreshControl+AFNetworking.h 2KB
UIRefreshControl+AFNetworking.m 4KB
AFAutoPurgingImageCache.h 6KB
AFNetworkActivityIndicatorManager.h 5KB
UIButton+AFNetworking.h 10KB
UIButton+AFNetworking.m 13KB
UIImageView+AFNetworking.h 6KB
AFAutoPurgingImageCache.m 7KB
UIWebView+AFNetworking.m 6KB
UIWebView+AFNetworking.h 4KB
AFURLSessionManager.m 54KB
AFURLResponseSerialization.m 28KB
AFHTTPSessionManager.m 15KB
AFURLRequestSerialization.h 21KB
AFURLRequestSerialization.m 50KB
AFHTTPSessionManager.h 19KB
GCDAsyncSocket
GCDAsyncUdpSocket.m 130KB
.DS_Store 6KB
GCDAsyncSocket.h 58KB
GCDAsyncUdpSocket.h 46KB
GCDAsyncSocket.m 220KB
SocketDemo
ViewController.m 2KB
Info.plist 1KB
main.m 329B
Base.lproj
LaunchScreen.storyboard 2KB
Main.storyboard 2KB
ViewController.h 210B
AppDelegate.h 272B
Assets.xcassets
AppIcon.appiconset
Contents.json 585B
AppDelegate.m 2KB
SocketDemo.xcodeproj
project.xcworkspace
contents.xcworkspacedata 155B
xcuserdata
Apple.xcuserdatad
UserInterfaceState.xcuserstate 15KB
xcuserdata
Apple.xcuserdatad
xcschemes
xcschememanagement.plist 482B
SocketDemo.xcscheme 3KB
project.pbxproj 36KB
共 85 条
- 1
资源评论
- SCART2018-12-20it is a good demo for sending message.
- pp4202020-11-17很好用的,方便很多,感谢分享
- mmorss2017-12-30said again or else can not download
- jiangxigui02722017-09-29have a try I am a little white!
- a52303062019-01-08很好用,方便很多,感谢分享
吴彦祖666
- 粉丝: 99
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功