4.5 seconds is extremly long. Usually the LAG is the most significant part of the transmission time. Acceptable lags may be 200 millisecs for eg. fps games. But even there the program needs to utilize dead rekoning etc. to allow pseudo-realtime synching.
Try to send only one little packet, containing only about 4 bytes. In a LAN this needs to be sent in a few millisecs.
When testing a client and a server on the same machine, the lag and transmission time may be much higher, because one of the two apps usually has a low priority. Anyway, when using multiple machines in a LAN you should get much better results!
Also, make sure not to kill the server by transmitting repeatedly data, as well as the other way. Instead use a polled timer event that is sending packets only when a certain time has elapsed, regardless of the framerate of the game:
t=millisecs()
if t>= time_for_packet
time_for_packet=t+500
; send packet here...
endif
so this one is sending a packet ever 0.5 seconds.
Try to send only one little packet, containing only about 4 bytes. In a LAN this needs to be sent in a few millisecs.
When testing a client and a server on the same machine, the lag and transmission time may be much higher, because one of the two apps usually has a low priority. Anyway, when using multiple machines in a LAN you should get much better results!
Also, make sure not to kill the server by transmitting repeatedly data, as well as the other way. Instead use a polled timer event that is sending packets only when a certain time has elapsed, regardless of the framerate of the game:
t=millisecs()
if t>= time_for_packet
time_for_packet=t+500
; send packet here...
endif
so this one is sending a packet ever 0.5 seconds.