2

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?

4
  • 2
    why -1? What is wrong with my thread? Commented May 22, 2012 at 13:02
  • 1
    Don't know either, it's a valid question. The aspect you have to consider is how embed the keepalive mechanism into your existing traffic. If you've been using an ObjectOutputStream, you should stick with that approach. Deserializing small objects from an OOS shouldnt affect your perfomance. Commented May 22, 2012 at 13:18
  • @Trixmix: I know nothing of the downvote, but you should know that SO is not a forum and therefore this is not a thread, but a question. ;-) Commented May 22, 2012 at 13:22
  • Yeah I'm used to forums thanks for the correction! Commented May 22, 2012 at 14:05

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

So if I make a pretty big game using the object stream it should not create network lag but may affect performance client side?
would it decrease performance enough to the point of barely playable even if you dedicate more ram?
Can you quickly answer my question please?
RAM has not much part to play in it. Can you clarify if you are worried due to network lag due to heartbeat or object (de)\serialization. If you are desiging the Network Game, then my suggestion will be to stick with basic datatype.
I am designing a game that would function both in singleplayer and multiplayer. I have created the basics of single player and wanted to early on implement multi player for later use. So its not like the entire game is Server/client its just the multiplayer part of it
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.