2011-12-14 99 views

回答

2

你應該閱讀AsyncSocket.h,下面是非常接近頂部(第一回調實際上給你的斷線的原因的信息,其可以有用)

/** 
* In the event of an error, the socket is closed. 
* You may call "unreadData" during this call-back to get the last bit of data off the socket. 
* When connecting, this delegate method may be called 
* before"onSocket:didAcceptNewSocket:" or "onSocket:didConnectToHost:". 
**/ 
- (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err; 

/** 
* Called when a socket disconnects with or without error. If you want to release a socket after it disconnects, 
* do so here. It is not safe to do that during "onSocket:willDisconnectWithError:". 
* 
* If you call the disconnect method, and the socket wasn't already disconnected, 
* this delegate method will be called before the disconnect method returns. 
**/ 
- (void)onSocketDidDisconnect:(AsyncSocket *)sock; 
1

看來,您使用的委託方法:

- (void)onSocketDidDisconnect:(AsyncSocket *)sock; 
+0

非常感謝。 – user403015 2011-12-14 14:01:03