On Oct 8, 11:48 pm, Gordon Beaton <n....@for.email> wrote:
On Mon, 08 Oct 2007 08:24:08 -0700, solomon13...@gmail.com wrote:
Now I open two whiteboards. When I draw one whiteboard-1, the
coordinates are send to the server. Now the server receives the
coordinates and send's the coordinate back to whiteboard-1. The
problem I am facing is it does not return the coordinate to
whiteboard-2 as well. How do I solve the problem?
Your client should be making one connection at initialisation, not one
connection for every mouse event.
Your server needs to maintain more than one connection. Data it
receives on any connection must presumably be sent to all of the
others, but as it's currently written it can still handle only one
client at a time.
Did you read and understand the Java networking tutorial? It shows how
to make a simple server that can handle multiple clients.
The first step to achieving this is to separate the part of the server
that accepts incoming connections from the part that actually handles
the connected clients.
I implemented threads for my server side.
public class KKMultiServer
public static void main(String args) throws IOException
ServerSocket serverSocket = null;
boolean listening = true;
serverSocket = new ServerSocket(9000);
catch (IOException e)
System.err.println("Could not listen on port: 9000.");
public class KKMultiServerThread extends Thread
private Socket socket = null;
public KKMultiServerThread(Socket socket)
this.socket = socket;
public void run()
oos1 = new ObjectOutputStream(socket.getOutputStream());
oos2 = new ObjectInputStream(socket.getInputStream());
ht1 = (Vector)oos2.readObject();
However it does not send the coordinates to all the clients.
the "writeObject()" call only to the client that sent the object. Where is
ArrayList. You can't need the synchronization feature, can you/
I truly hope you start answering questions.