2011-12-14 2 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

+0

나는 서버가 닫힐 때이 메소드들 중 아무 것도 호출되지 않는다고 생각한다. :(나는 서버가 닫히고 있다는 것을 어떻게 알 수 있는지 모른다. – Geri