Socket does not receive or send a message to the server

-1

I'm implementing a Java multi-threaded server that receives messages from clients and makes a broadcast of them to others. But I'm having problems. The server only receives the messages sent to users when users' sockets are closed.

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

Here is the code for my GitHub project for those who feel the most willingness to see them there. Please checkout the branch test and not master

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

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

    
asked by anonymous 15.04.2018 / 00:00

2 answers

0

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

    
15.04.2018 / 01:53
0

Every time you write something through a PrintWriter object it is highly recommended that you call the flush () method to "unplug" the output. Then as the friend already said: After socketWriter.write(line) type socketWriter.flush() .

    
15.04.2018 / 18:59