This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Java networking problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Java networking problem" Watch "Java networking problem" New topic

Java networking problem

Kasem Boonmun

Joined: Dec 14, 2003
Posts: 4
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

[ January 04, 2004: Message edited by: Kasem Boonmun ]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
What does your client look like?

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Sockets and Internet Protocols forum...
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
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.
I agree. Here's the link:
subject: Java networking problem
Similar Threads
client-serer...plz help
cleint-server interaction
I/O stream from Socket not ready
Java networking, nothing happens
Two way chat?