Problem with echo server and client.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
HAllo.
I am staring and staring at my code below but can not work out what i have don wrong.
A client connects successfully to the server and gets the message "Echoserver running" from the server but when writing to the server nothing happens. A hint to make me locate the logical flaw would be nice!
Client:
Server:
I am staring and staring at my code below but can not work out what i have don wrong.
A client connects successfully to the server and gets the message "Echoserver running" from the server but when writing to the server nothing happens. A hint to make me locate the logical flaw would be nice!
Client:
Server:
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
1) Change the == on line 50 of EchoClient to !=
2) Don't println to a socket. Instead of using println(), use print, explicitly print out the line separator you want, and manually flush:
After these changes your echo server and client are working just fine with me.
2) Don't println to a socket. Instead of using println(), use print, explicitly print out the line separator you want, and manually flush:
After these changes your echo server and client are working just fine with me.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Reiner Herman
Greenhorn
Posts: 19
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thank you for the reply.
The changes does not make it work for me. I changed to use print and adding "\r\n" and flushing instead of println when to socket streams.
The changes does not make it work for me. I changed to use print and adding "\r\n" and flushing instead of println when to socket streams.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Did you also change the == into != ?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Reiner Herman
Greenhorn
Posts: 19
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Yes. But of course I should also remember to move the System.out.println inside the while loop when changing == to !=. And now it works
)
Thank you very much for the help. Should have asked a few days ago ! Especially the problem with println was tricky I think. I am nos sure that I understand why the == does not work. I will think a little more about it.
) Thank you very much for the help. Should have asked a few days ago ! Especially the problem with println was tricky I think. I am nos sure that I understand why the == does not work. I will think a little more about it.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
readLine() will return null when you've already read all there is to read. So the loop was executing exactly zero times, because the condition was false from the start.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
| The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |












