Server Client correct socket communication

Hi,

i have a server that works correctly and i have a client. All i need to know is how to make these 2 communicate without having my applet slow down or, not even work at all.

My problem is like this. I can have my server have input.readline() in its run method, (on the whole time )and it dosn't mess up or slow down even if it recieves nothing at all, but if i have the same input.readline() in my applet's run method, and the applet dosn't recieve a message, it screws up the applet and it displays nothing at all. I've been stuck on this for 20 lines for the last 4 days and i'm going bald over it. The following code dosn't work for my applet because it's not recieving any info in the input.readline()

server:

try

{

output.println("hey from the server");

String ln = input.readLine();

if(ln != null){

read_input(ln);

}

}

catch (IOException e) {

System.err.println("server I/O error");

}

finally{

try {

client.close();

}

catch (IOException ee) {

System.err.println("close error");

}}}

client:

try{

output.println("hey from the server");

String ln = input.readLine();

if(ln != null){

read_input(ln);

}

}

catch (IOException e) {

System.err.println("server I/O error");

}

finally{

try {

client.close();

}

catch (IOException ee) {

System.err.println("close error");

}}}

[1524 byte] By [killeska] at [2007-10-3 11:49:59]
# 1
use Thread
angeles1016a at 2007-7-15 14:23:38 > top of Java-index,Java Essentials,Java Programming...
# 2

i am, my server_connection_client, which communicates to the client uses thread. I can get this working:

when the client moves his mouse, the mouseMOVE method sends a message to the server with the mouse_x_pos, and the server writes back with the same value, and it is read in the mouseMOVE method. So i can update the server no bother, its just lets say that, if i have 2 clients, client1 and client2, and they both see where the others mouse_x_pos is, client1 moves his mouse and client2 does not, how do i get client2 to see where clients1 mouse_x_pos. When ever i set the applet to readLine() and nothing is sent to it, it craches my applet for some reason. Any ideas or suggestion to get around this?

killeska at 2007-7-15 14:23:38 > top of Java-index,Java Essentials,Java Programming...
# 3
ah ok.. so your problem is you need to have a multiple client to connecto to your server?
angeles1016a at 2007-7-15 14:23:38 > top of Java-index,Java Essentials,Java Programming...
# 4
if you need to have a N-client to 1 server then you need to have a separate thread for each client.. you can check on this: http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html#latercheck on the code: KKMultiServer.java and
angeles1016a at 2007-7-15 14:23:38 > top of Java-index,Java Essentials,Java Programming...