> 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

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
eksamor@yahoo.com - 18 Sep 2006 11:59 GMT
Gordon Beaton skrev:
> > My client block after typing the first input...any ideas?
>
[quoted text clipped - 7 lines]
>
> /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.
Gordon Beaton - 18 Sep 2006 12:14 GMT
> 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();"
Confirm using Ethereal or similar tool, that the data really gets sent
to the server.
Try doing out.flush(), or setting "autoFlush" when you create the
PrintWriters (at both ends of the connection).
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e