Here's a ready-baked code from the Head First Java book, for the Server and Client codes. The problem I am having is trying to get the client to send a test message, and then receive it back. I can't get it to work. I have added a few lines to the client code to send the test message. Where have I gone wrong?
When I run it, the server accepts the client connection. But it doesn't print the test message the client sends. It seems it hasn't received it. So, I don't know if the client has really sent the message. If it did, I don't know why the server failed to read and print it.
This is the Server code, instead of me just referring you guys to the book. If the code is too long, I apologize in advance. The client code is also below.
This is the simple client code. Again, from the Head First Java.
Thanks in advance! Karen
amerzil co-ed student<br />"Praise be the Code"
Joined: Oct 08, 2001
Your server is stuck trying to read a line. Instead of sending "Hello" from the client, send "Hello\n", and it will work.