Java NIO DatagramChannel question

Started by elias4444, September 21, 2005, 18:35:27

Previous topic - Next topic

elias4444

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

Dansas

TCP does not cause lag. Its how you use it.

elias4444

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

Dansas

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.

elias4444

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