Skip to main content
gamedev.net
🔒 Locked

[java] Objects over sockets

Started by Si Hao Sep 19, 2006 at 4:53 AM 2 replies 750+ views
Original Post
Si Hao
Si Hao
I created a new thread since I do not want to hijack the other thread about java sockets. Some of the posts in that thread mentioned that sending objects over sockets are expensive. Currently I am using a simple event based client/server engine. For example, player moves 2 hexes to right, client will create an event object containing neccesary data in a hashmap (probably containing the destination hex number as well as player name that moved) and send it over to the server. Once it reaches the server, server will process the event according to the type of event object received. Now I have a question, is this method expensive? Currently everything is running smoothly, though there is not much content yet.
CaptainJester
CaptainJester
It is expensive yes. However if you are just writing a turn based game or a light two player game, it should be sufficient.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
Son of Cain
Son of Cain
Hi,

I agree with Captain here. It is expensive, yes, but for most (simple) games it is by far Ok. There are plenty of optimizations you can do to squeeze even more performance out of it, if you so want. You should be fine with it on simple games.

The reason we advice against using it is for 1) Prevent people from having the bright idea of sending complex, heavyweight game objects and states over the network, and 2) Allow for easier scalability on the server side - using NIO, you can easily increase your scalability.

Rodrigo
a.k.a javabeats at yahoo.ca
Si Hao
Si Hao
Thanks for the replies I will just use my current engine for my current game and probably make a new engine for my next one.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.