Domanda

When I have a TCP connection that uses packets.. (Server / Client Application) Should I keep sending a packet back and forth (Between the server and client) just to see if the connection is alive or is that unnecessary? like a KeepAlive packet..

another question is does it make a huge difference (performance wise) if I send an int (DataOutputStream) though a stream instead of sending a Packet object (ObjectOutputStream) which has like an average of 5 fields at least 3 methods and some getters and setters? would it make such a big difference performance wise?

È stato utile?

Soluzione

Yeap. This is called heartbeat. This help recevier of heartbeat to detect if there is problem in connection. Regarding the second part, if you try to send the object than it need to be deserialize and serialze. This will surely have the impact on performance. If you want to know the performance from network lag percpective than it should not be much difference.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top