Hello Guest

Java NIO DatagramChannel question

  • 4 Replies
  • 10497 Views
Java NIO DatagramChannel question
« on: September 21, 2005, 18:35:27 »
A little off topic here, but I figured you guys could me with this. My next game is heading for the multiplayer world, but apparently TCP causes too much lag. I'm trying to implement UDP (datagram) in my networking code, but can't seem to figure it out. Anyone know of a good resource/tutorial about NIO stuff? I've googled it every way I can think of.

BTW, my main problem is that you can only accept() a new client via TCP Sockets - so I'm trying to figure out how to open a Datagram socket off of that once the client has been included.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Java NIO DatagramChannel question
« Reply #1 on: September 21, 2005, 19:41:14 »
TCP does not cause lag. Its how you use it.

Java NIO DatagramChannel question
« Reply #2 on: September 21, 2005, 19:44:13 »
I was just experimenting with that actually... after I noticed that WoW is all TCP (hey, if they can do it with millions, I can sure find a way for only a few people to connect). I think my main problem is the timing of when I send the packets. I was originally saying to send a packet anytime something changed - but now I'm wondering if it's just better to send a new packet of information so many times per second. Any ideas?

Maybe a mix of the two?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Java NIO DatagramChannel question
« Reply #3 on: September 21, 2005, 20:16:02 »
What you should send:Only what you see on the screen, everytime something changes. Remember, always send the bare minimum.
Theres an exception to that though- If something has information that the user might want to check later, aka monster name- send it only once, when the object appears in memory/screen.

Java NIO DatagramChannel question
« Reply #4 on: September 21, 2005, 22:01:59 »
WooHoo! Got it! TCP is working just fine now. Those NIO channels can be tricky, but I cleared up the threads and, sure enough, TCP is lightning fast.

Thanks again!
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com