socket.close() on both sides?
799873Oct 4 2010 — edited Oct 5 2010Hello
i'm creating a server-client application, but i came at a problem:
i currently testing the logging out or disconnection.
The protocol does this: client sends packet to server with request for logout, server pushes response back and ?closes socket?, client reads response and ?closes socket?
now this is where i don't understand what i should do... should i close the socket on server side, or at client side ?
the thing is after the server received that packet, it sends packet back for confirmation and then unregisters the client, this means removing it from the client list (where it holds all clients for updating purposes at server side etc) and it closes its read/write thread, so stopping the thread from running. but should i also close the socket then?
or should i let the client close the socket? because while i send my packet of logout and receiving it, im also pinging (sending empty packet) the server to make sure the server is still online and server writes response back (this is a default operation, every 600ms), and when i close the socket on server side this will give offcourse an exception at clientside before i received the packet, so what should i do ??
Thanks in advnace!