Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

having a general socket problem  RSS feed

 
shawn larkin
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while(br.readLine() != null)
{
pw.println(br.readLine());
}
this seems like basic code that's echoing back what the socket has sent. But when I connect with Telnet, I have to type input twice to get a response.
eg.
> shaun
> shaun
> shaun <--- response after data input typed twice.
 
Yongping Wang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your code
while(br.readLine() != null)
{
pw.println(br.readLine());
}
TO
String temp ;
while((temp = br.readLine()) && temp != null)
{
pw.println(temp);
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!