Yes, and which client(s) receive what is written to that outputstream?
Printable View
Yes, and which client(s) receive what is written to that outputstream?
in Clients handShake()
Code:private void handShake() throws IOException
{
String message;
String value[];
value = new String [100];
try {
output.writeObject(Client_name);
output.flush();
input = new ObjectInputStream(client.getInputStream() ); //<--------------------
I know there is one client that does, the question is:Quote:
which client(s) receive what is written to that outputstream?
How many clients receive any messages when the server sends a message?
Look at the my print out again.
i am am intending it for every client that connects but appearantly just one reads it..
You must see what the program is really doing.Quote:
i am am intending it for every client that connects
Do you understand my question?
How many clients receive any messages when the server sends a message?
The answers could be:
only one
the last two
all of them
Chose one of the above.
all of them
Can you show that by adding print outs to the client class that shows that it has received a message?
Then start more than one client and see if the all of them receive all of the messages that the server sends.
If you look at my posted print outs you will see what I saw when I ran the above test.
actually, only one client sees the message.
Yes, that is what I think.
The question now is: Why does only one client get any messages?
And why only the last client?
That sounds like a variable is being written over with the value that 'points' to only the last client. The value for the previous clients is gone.
i have removed the what seemed to be over writing the dat, but am getting continious loop of the message
Code:while ( !message.equals( "." ) ){
value[i++] =message;
//message = (String) input.readObject();
userList.setListData(value);
What variable has the reference for the outputstream used to send to the client? That variable 'points' to the last client that has connected. The previous value in that variable was overwritten and lost.
should this be taking me back to the for loop?
the variable name is output if thats the question you are asking
thank you MR Norm... u've been great help.. am just knida dumb obviously:(giggle)::(-:
Glad you figured it out.
i havnt yet, but i will eventually, i'll just keep struggling with it. cos i know u have given every clew available...
Have you considered keeping a list of connections, one for each client, so that you can communicate with each of them, not just the last one to connect?
given up, tnx..
Strange. You know how to save objects in the clientList array and send all of its contents to one client.
How about saving the values of the output object in an array and use the contents of that array to be able to send messages to each of the clients. You'd need a nested loop. Outer loop gets the value of output to use to send a message to the next client. Inner loop sends the messages from the clientList array to that client.
hi eventually Got what u have been saying, but i had to make alot of changes. thank you, but now i have a different problem :). kind of related but i tried all i could as wel but theres just something am not doing right and probably which i dont know. i dont know if i should open a new thread edit this one, however since you are not online, i will open a new thread. thank you very much..