What is the best way to know if a message has arrived on client? I'm using a BufferedWriter
to send a message and it sends away the message. I could use an answer from the client and read it on the server, but I would like something faster
Socket socket = MainServer.map_socket.get(person);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
bw.write(msg_date + " " + mittente + " " + testo);
bw.newLine();
bw.flush();
I'm using this code to send messages from server. It retrieve the socket from a map using a key, the problem is when the client closes the connection and Bufferedwriter
sends the message (and obviously it doesn't arrive to the client).