How to synchronize sockets?

Hi, I磎 working with sound files which have to be played in different computers at the same time. Then I think the best way to do it is to synchronize the Sockets of the clients that are connected to the same server. But how can I do it?Thanks..bw.
[268 byte] By [berlinerwurma] at [2007-11-27 2:18:13]
# 1
Basically you can't. TCP does buffering and asyncrhonous writing to the network so there is no way to even get the data sent simultaneously with any guarantee, let alone received and played simultaneously.
ejpa at 2007-7-12 2:17:30 > top of Java-index,Core,Core APIs...
# 2

First, if the sound stream is unending(streaming media), you might want to use UDP and allow packets to be lost. This is simply the only way for the sound to play as it is being sent. With TCP, packet loss would result in the receiver "lagging" behind the source as it aims to receive every last packet. It's sort of like frameskip: You have to drop a bit to keep up the speed.

If the sounds are finite-length, you might try first uploading the entire sound, then issuing a "start playing" command once all receivers are ready.

Mind you that there is simply no way to get 100% accurate timing over network connections. Even clock synchronization protocols must allow for a few milliseconds loss, and those go to great lengths to minimize the timing error. Full synchronization is simply not an option: Every network has inherant delays to it, and those delays have inherant randomness to them, as well as variance from connection to connection. There is no way to rectify that.

SlugFillera at 2007-7-12 2:17:30 > top of Java-index,Core,Core APIs...