This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java networking problem

 
Kasem Boonmun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm learning Java networking(IBM class). As a beginner, my code is compile and run smoothly except it displays one only one message on console even though I try re-send the message again and again. Would you please to help me out? Do I miss a thing?
Thanks in advance
Kasem

[ January 04, 2004: Message edited by: Kasem Boonmun ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most likely cause is that you need to flush and close the BufferedReader at the end of your while loop. This sort of program works better when you start a separate thread for each request but that is probably beyond the scope of your study right now.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your client look like?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Sockets and Internet Protocols forum...
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want the server to echo more than just a single line, you'll have to replace

with a loop that reads in lines and prints them until readLine() returns null. It's also a good idea to close the stream/socket when you're done with it, as Michael mentioned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic