#import "NSObjectGCDAsyncSocket.h"
@implementation NSObjectGCDAsyncSocket
{
GCDAsyncSocket* socket;
}
+(NSObjectGCDAsyncSocket *)defaultSocket
{
//socket只会实例化一次
static NSObjectGCDAsyncSocket* socket=nil;
//保证线程安全,defaultSocket只执行一次
static dispatch_once_t once;
dispatch_once(&once, ^
{
socket=[[NSObjectGCDAsyncSocket alloc] init];
});
return socket;
}