Forums Register Login

BufferedReader's readLine() is giving null when listening for the socket connection for second time.

+Pie Number of slices to send: Send
Hi Ranchers,
This is a simple one-way interaction (from server to client) client-server program that makes changes on the client-side on the basis of whatever is being sent from the socket over server-side. There is absolutely no issue on the server but on the client-side, BufferedReader's readLine() method is giving "null" even when nothing is being sent over the socket from server-side. I've read the article Don't println() to a socket in I/O FAQs and tried implementing the solution provided but unfortunately the issue remains unsolved. Here, I've also marked where exactly the problem is coming (on the client-side) as you move along the code which is as follows:

Server-side code:


Client-side code:


This class is on client-side.



If you wish to run this, create a file "MappingFile.txt" & fill it line-by-line such that x1:1 and so on till x8:8
And yes, I'm using Windows OS.

Thanks..

+Pie Number of slices to send: Send
Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.
+Pie Number of slices to send: Send
Thanks Tony...will be surely careful in future..
+Pie Number of slices to send: Send
Your send actionListener closes the stream after sending the text (in the finally clause) and readLine() returns null when the end of the stream has been reached, which it has when the stream has been closed.
+Pie Number of slices to send: Send
Thanks Tony... the issue has been resolved!!
+Pie Number of slices to send: Send
My pleasure
You get good luck from rubbing the belly of a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 4277 times.
Similar Threads
Substituting the value to the equation(loop)
master exam doubt
Can't Understand... K&B Mock Exam
urgent help on K&B chapter 7 Self Test Questions
Master Exma question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:41:18.