Multiply clients connecting to a single server

Hello!

I'm trying to have multiply clients connecting to one server and the problem is that its listening only to one client :-(

The server:

ServerSocket server =new ServerSocket(32222);

System.out.println("server started...");

//waits here for the client to start...

Socket s = server.accept();

System.out.println("Client found...");

BufferedReader sr=new BufferedReader(new InputStreamReader(s.getInputStream()));

PrintWriter p =new PrintWriter(new OutputStreamWriter(s.getOutputStream()));

System.out.println("Created stream...");

BufferedReader kb =new BufferedReader(new InputStreamReader(System.in));

while(true){

System.out.println(sr.readLine());

}

The client:

try{

Socket s =new Socket("127.0.0.1", 32222);

System.out.println("Connected...");

PrintWriter p =new PrintWriter(new OutputStreamWriter(s.getOutputStream()));

BufferedReader sr =new BufferedReader(new InputStreamReader(s.getInputStream()));

System.out.println("Created stream...");

BufferedReader kb =new BufferedReader(new InputStreamReader(System.in));

p.println("client");

p.flush();

while(true){

String str = kb.readLine();

p.println(str);

p.flush();

//System.out.println(sr.readLine());

}

//s.close();

}catch(Exception e){

e.printStackTrace();

}

Now, once I'm running the server, and running a client, the client sends information no problem. But - when I run another client session, the server ignores the second connection, and still receives messages from the first one, and only from the first one.

Am I doing something wrong?

Thanks in advance!

[2901 byte] By [kampana666a] at [2007-10-2 5:52:56]
# 1
Solved! thanks anyway :-)
kampana666a at 2007-7-16 2:02:30 > top of Java-index,Core,Core APIs...