Solved

RTS networking datagram Java strategy help needed

Posted on 2011-09-13
3
295 Views
Last Modified: 2012-05-12
Hi,

For my Java RTS,

I am now doing the networking. I can send datagrams between server and client,
but with limited bytes, how should I convey movement directions for multiple units?

I think a major problem is bytes are too small for the data members I am using, integers and possibly occasional strings.
In my arrays of unit X and Y positions, what is the simplest way to send all client (player) data to server, and on to each client?

Could I make a struct array of all the relevant data members for each unit? X, Y, HitPoints etc
and have a method to send and receive arrays of structures?
Is there something as simple as toByteArray() and getByteArray()? for objects / struct arrays?
For synchronization, should each client send out movement info for each frame? - or only when an instruction( move) occurs?

Any other comments?

Should I use a struct in the connection that contains fields for every possible communication need?
I may need an initial header up front containing synch info (frame counts)

What else?

Thx
0
Comment
Question by:beavoid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:SteveJ
ID: 36540008
I dont understand your app. You say "bytes are too small" and Im not sure what you mean by that, because the obvious response is send more bytes. Java as I sure you know has lots if methods for sending data .  .  . and whether or not you send field names etc has to do with your app not Java read / write operations. And try to use the upper layer protocols so that you are not re-writing TCP/IP.

Good luck,
Steve

By the way, java and gaming? Im no programmer but Id think java was eay too slow for gaming. C?
0
 

Author Comment

by:beavoid
ID: 36540463
In my case, Java is perfect.
I think, now, I'd like to know how I can send a whole struct of data members between two sockets. By two small, I simply meant that bytes are smaller than ints and Strings. and sockets only send bytes.
Can I design a struct (must it be a class?) that contains all data I'll need to communicate and send it safely between sockets, even though it must be byte sized data?
0
 
LVL 40

Accepted Solution

by:
noci earned 500 total points
ID: 36541670
If you need 1 to many cummunication you might opt for Multicast.
That is not relyable in the sense that UDP is employed and you cannot ask for a retransmit on the multicast ports....

If it point -> point then you have to devise some protocol of your own.
The data to be conveyed needs to be put in some structure that you send around as a packet.
Keep it small so updates allways fit in one MTU.

I have no experience with java except that for realtime stuff it tends to degrade.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question