Re: Client blocks!
Gordon Beaton skrev:
On 18 Sep 2006 02:24:55 -0700, eksamor@yahoo.com wrote:
My client block after typing the first input...any ideas?
Your server is waiting for input from the client.
Your client reads input from the user, does nothing with it, then
waits for input from the server.
In other words, both client and server are waiting for each other to
send something that will never arrive.
/gordon
Ok I have now changed the while loop in the client to:
while ((fromUser = user.readLine()) !=null)
{
System.out.println("test");
out.println(fromUser);
fromServer = in.readLine();
System.out.println(fromServer);
}
and the while loop in the Server to:
String fromClient = null;
while ((fromClient = in.readLine()) != null)
{
System.out.println("read from in channel");
out.println(fromClient + " received at server!");
System.out.println(fromClient);
}
now the procedure is as follows:
1) Server starts and block until Client connects (accept() blocks)
2) Client connects and blocks until user types input.
3) Server continues to while loop and blocks until there is data in the
in channel.
4) A client types "bong" and "test" gets printed and "bong" get send to
the server. The it block in the line "fromServer = in.readLine();"
5) Now the server should stop blocking since "bong" is in its in
channel, but it does not!
the while loop never gets executed on the server.