如题,我在子线程main函数里面开了一个socket,main函数走完socket的代理完全没有进行回调,求解这是什么情况。
解决方案 »
- Xcode4.6-->Hello Wolrd疑问
- 携程应用开发大赛 -- 组队邀请
- 服了 关于cocos2d 用nsmutablearray读plist的问题。
- iOS解析XML文档问题
- 求问关于ffmpeg流媒体客户端AudioQueue设置
- 怎样把的Xcode生成的xxx.app制成的ipa安装到已越狱的iphone上
- iphone UIButton中Image频繁切换的问题
- 新人使用APPCAN生成安卓和IOS遇到的超难问题!!!!!!!!!!
- 手机淘宝详情也商品数据对象设计
- 如何在wkwebview下,xcode控制台输出console.log
- Xcode4.6 storyboard视图中找不见identifier了?····
- 创建UITableViewCell
@implementation ZBOperation@synthesize asyncSocket;
@synthesize host;- (id)initWithhost:(NSString *)hostip
{
if (![super init]) {
return [super init];
}
self.host = hostip;
return self;
}- (void)main
{
self.asyncSocket = [[AsyncSocket alloc]initWithDelegate:self];
[self.asyncSocket connectToHost:self.host onPort:5867 withTimeout:-1 error:nil];
NSLog(@"%@",self.host);
}- (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err
{
NSLog(@"onSocket:%p willDisconnectWithError:%@", sock, err);
}- (void)onSocketDidDisconnect:(AsyncSocket *)sock
{
NSLog(@"onSocketDidDisconnect:%p", sock);
}- (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)hostip port:(UInt16)port
{
NSLog(@"onSocket:%p didConnectToHost:%@ port:%hu", sock, hostip, port);
[sock readDataWithTimeout:-1 tag:0];
}- (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
NSString* aStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"===%@",aStr);
}