Socket does not receive or send message to the server

Asked

Viewed 47 times

0

I am implementing a Java multi thread server that receives messages from clients and broadcasts them to others. But I’m having problems. The server only receives messages sent to users when the users' sockets are closed.

The application is divided into two modules: client for customer codes and server for the server codes.

Here is the code of my project on Github for those who feel more comfortable to see them there. Please check out the branch test and not in the master

The codes are all very well commented and simple to understand.

As I already asked this question in the English stack overflow, I will just put a link to it here. The codes are all there.

2 answers

0

Call PrintWriter.flush() after each write() sending message to make the data effectively transmitted.

0

Every time you write something through a Printwriter object it is highly recommended that you call the flush() method to "uncouple" the output. So as the friend has already said, After the socketWriter.write(line) write socketWriter.flush().

Browser other questions tagged

You are not signed in. Login or sign up in order to post.