Solved

RTS networking datagram Java strategy help needed

Posted on 2011-09-13
3
294 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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Suggested Solutions

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Suggested Courses

739 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