I am getting a flushing problem. I am spawning a threaded handler from the server side where I pass the socket reference to handle the communication.
On the server side, while shutting down I tried the two methods I pasted above to close client sockets(handler) thread .But the problem persists. I am unable to receive the "SHUTDOWN" string at the client end using either of the two methods above. Kindly advice. Regards, Anand Kapadi
I apologize. I thought you had an infinite loop in your server code. Please Use Code Tags in the future to preserve your code formatting. As for your problem, I know BufferedWriter will need to be flushed after writing data to it. PrintWriter should work the way you have it coded (autoflush = true and using println()). If you don't see the results you expect, I recommend adding a bunch of logging to make sure your code is doing what you think it is doing. The java.util.logging API makes this easy to manage.
Actually, I'm pretty sure that the flush() call does send the data. But the receiving app might not know to flush its output text without that line-termination.
Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners