Solved

RTS networking datagram Java strategy help needed

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Switch Uplinking Arista to Force 10 5 39
servlet example 11 40
spring jars download 1 27
Unauthorized Network Devices Appearing on Home Network 20 110
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
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.
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…
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…

777 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