Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RTS networking datagram Java strategy help needed

Posted on 2011-09-13
3
Medium Priority
?
298 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
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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

963 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