wood burning stoves
The moose likes Sockets and Internet Protocols and the fly likes Problems getting response from server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problems getting response from server" Watch "Problems getting response from server" New topic

Problems getting response from server

Ray Zeigler

Joined: Jul 06, 2012
Posts: 18
Hi I was wondering if someone could figure out why my code isn't working. I cant seem to figure out how to structure my code in such a way that I can send a receive multiple messages. How should I structure this so it doesn't get stuck after the first input?I know the problem lies in my if statements. Just not sure where. Ive tried restructuring it but no luck, if(userinput.contains("")) is how I tried to continue but it obviously doesn't work. Any suggestions on how to remedy this would be great!

Here's my client code:

Server Code
John Jai

Joined: May 31, 2011
Posts: 1776
The client programs wait for the server to respond in the below line of code.

But as you see the TCPServer do write using outToClient. The problem I guess is that the BufferedReader's readLine() method needs the line separator to read the line.

Read http://docs.oracle.com/javase/6/docs/api/java/io/BufferedReader.html#readLine()

So add the line separator while writing from the server like outToServer.writeBytes(userinput + '\n');
Ray Zeigler

Joined: Jul 06, 2012
Posts: 18
Wow that was it! Your my savior thanks so much. The problem was all with the new line.
I agree. Here's the link: http://aspose.com/file-tools
subject: Problems getting response from server
jQuery in Action, 3rd edition