Laurent Crivello
Laurent Crivello

Reputation: 3931

How to detect remote disconnection in ASyncSocket

I am using ASyncSocket on Cocoa, however when the remote host disconnects I don't get the onSocketDidDisconnect event (maybe once every 5 tests). The -isConnected method returns me TRUE.
How can I detect a remote host disconnection ? Thanks !

Upvotes: 1

Views: 110

Answers (2)

Laurent Crivello
Laurent Crivello

Reputation: 3931

How I implemented this is by all clients registering themselves every x seconds or minutes. If a client disconnects, no registration anymore so I consider it as not connected.

Upvotes: 0

Manav
Manav

Reputation: 10324

AsyncSocket will not report disconnections by the remote peer if there is no read enqueued. It's a bug I think in CFStream itself (don't quote me on this). By having a read always enqueued we seem to get along fine.

Upvotes: 1

Related Questions