Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Nov 2005
Offline Last Active Oct 02 2016 09:06 AM

Posts I've Made

In Topic: Power Up Table Tennis Contest

27 September 2013 - 11:30 AM

Is it too late to enter this contest? I would like to participate.

In Topic: Hello

05 November 2007 - 01:32 AM

Hmm, wow yeah. We'll see what happens ;)

In Topic: Java: Network Game Lag

18 March 2006 - 05:33 AM

I've been working with Sockets for about three weeks, and I haven't come across a single connection problem with them. Only lag and out-of-sync problems (in games).

Anyway, back on topic... it can't be latency. I had my friend ping me (through my router) and the time it took was between 100-105ms (milliseconds). And he lives in New York, so it's not like he's next door ;).

I tried using Datagram Sockets but those are much more confusing than TCP Sockets. I couldn't figure out how to use them to make an RTS.

I know there has gotta be some way to fix this...

In Topic: Java: Network Game Lag

17 March 2006 - 10:00 AM

Okay, I've changed my code and I've completely rewrote my run() method. I changed the FPS to 10 and I'm now using non-blocking sockets. The lag is completely gone now, however, now the game is completely out of sync (synchronization). When I test it on my localhost (with myself), it seems to work without lag and it's almost perfectly in-sync. But when I upload it and test it (with myself), it's completely out of sync. What can I do?

Take a look at my changed source-code:

Oh and I couldn't find anything even about Java on gaffer.org.

Maybe I should try and rewrite my code to use Packets?

In Topic: Java: Network Game Lag

17 March 2006 - 07:48 AM

DaBookshah, I agree with the anonymous poster. I've worked with sockets only for a short time, and before I got into trying to make a multiplayer RTS with them, they've worked flawless. And even making a multiplayer RTS they should work flawless (I've seen it done), I just know I'm doing something wrong.

Anonymous poster, thanks for all of that great information. I saw something about using the Socket.setTcpNoDelay(true) when using sockets for a multiplayer RTS, and I tried it but it had no effect on blocking sockets. Maybe it should be used with non-blocking sockets?

I'll take a look at the DataOutputStream class.

Oh, and wouldn't Datagram Packets be a bad idea for a multiplayer RTS? Would the positions tend to jump around since the packets aren't guaranteed to arrive in the same order they were sent out? For example:

Frame 0 - Server - ballX = 0; ballY = 0;
Frame 0 - Client - ballX = 0; ballY = 0;
Frame 1 - Server - ballX = 5; ballY = 5;
Frame 1 - Client - ballX = 0; ballY = 0;
Frame 2 - Server - ballX = 10; ballY = 10;
Frame 2 - Client - ballX = 5; ballY = 5;
Frame 3 - Server - ballX = 15; ballY = 15;
Frame 3 - Client - ballX = 15; ballY = 15;
Frame 4 - Server - ballX = 20; ballY = 20;
Frame 4 - Client - ballX = 20; ballY = 20;

Notice how the ball would skip a position in Frame 0 and Frame 1 and then in Frame 2 it would appear to jump from Position 0 to 10.

I'm going to rewrite my run() method, and change my sockets back to non-blocking again. And I'll also try and repaint the screen whenever possible (I'll see if I can find that tutorial on how to do that).