File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Problem from a networking newbie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem from a networking newbie" Watch "Problem from a networking newbie" New topic

Problem from a networking newbie

Sven Thor
Ranch Hand

Joined: Jan 31, 2004
Posts: 34
I have problems when I try to run this simple textbook-like example.
The server starts ok. Writing data from the client to the server is ok. The server receives string and is supposed to write a string back to the stream connected to the client. However, the client hangs when it tries to read the result from the stream. I do not see why ?

I would think this would work without multithreading the server or using callbacks.


Joe Ess

Joined: Oct 29, 2001
Posts: 8927

You are reading until the end-of-stream:

But you aren't terminating the output stream on the client or the server. You can do that by invoking close() on the output stream or shutdownOutput() on the socket.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Problem from a networking newbie