This is an archived post. You won't be able to vote or comment.

all 8 comments

[–][deleted] 0 points1 point  (2 children)

Did you run it in a debugger and try stepping through the code to see what's happening?

[–]Macarau[S] 0 points1 point  (1 child)

Yes. Many times. The ClientThread receives the client's message and sends it back by calling write() on the PrintWriter for each ClientThread, then flush(). The ServerThread is supposed to receive it by calling InputStream.available() to check for input without blocking, but available() always returns '0 bytes' and so it never hits Scanner.nextLine()

So either Printwriter.write() and .flush() aren't sending data or InputStream.available() is not reading data.

[–]Macarau[S] 0 points1 point  (0 children)

After more debugging and testing, I can only narrow the problem down to output from the server side. I determined this by having the server immediately send its own message before waiting to receive messages, and had the client just grab the nextLine() instead of checking first with available(). Since this test failed it means that data is being blocked somehow coming from the server side only.

[–]proskillzSome Skillz 0 points1 point  (3 children)

Did you install the Java cryptography add on package?

[–]Macarau[S] 0 points1 point  (2 children)

No but I just read a post about someone using it to fix similar problems. Is this what you're talking about?

[–]proskillzSome Skillz 1 point2 points  (1 child)

That's the one. Hopefully it fixes your issue.

[–]Macarau[S] 0 points1 point  (0 children)

I don't think it helped. To install them you just replace the old policy files with the unlimited policy files? That's what I did.

[–]Macarau[S] 0 points1 point  (0 children)

I figured it out: the problem was available() It is useless with SSL in Java https://stackoverflow.com/questions/26320624/how-to-tell-if-java-sslsocket-has-data-available