views:

17

answers:

0

Hi all, Using AsyncSocket I made a simple text chat. I have found that sometimes during net inconsistency following delegate at server and at client code: - (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err, does not get called.

In this method, at client side, I am disposing socket connection established with server using:

[connectSocket disconnect]; // where 
connectSocket is an object of AsyncSocket,

and updating status of all users at client side to offline. At server side, I am notifying all other connected sockets about user_Id of user who has got offline due to socket disconnection so that in turn they can update online users list at there end. As its solution I am thinking to continuously PING client from server and server from client using some mechanism so that during net inconsistency also both server and client gets notified of each other's status.

Can anyone suggest me some better solution for it?? Also I want to inform you that in-order to read and write data continuously to socket connection established I have set timeout values to -1 in methods: readDataWithTimeout:tag: and writeDataWithTimeout:tag: , can this cause any problem in above mentioned case???

Thanks for any suggestion or help,

Miraaj