permaculture playing cards
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
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.


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:
subject: Problems getting response from server
It's not a secret anymore!