Java socket server only displays messages received after the connection closes -
i trying write code simple server, receives messages client. connection succesful once server connects client messages not displayed on screen. after close connection client side, server receives messages in 1 go.
i need receive messages line line because each line needs de processed individually , in real time (i using hmm driver's actions recognition).
could tell me doing wrong?
thanko much.
public static void main(string args[]) { serversocket my_server = null; string received_message; dataoutputstream output = null; socket socket_connected = null; try { my_server = new serversocket(9090); } catch (ioexception excepcion) { system.out.println(excepcion); } try { socket_connected = my_server.accept(); bufferedreader entrada = null; while (socket_connected.isconnected() == true){ entrada = new bufferedreader(new inputstreamreader(socket_connected.getinputstream())); output = new dataoutputstream(socket_connected.getoutputstream()); system.out.println("confirmando conexion al cliente...."); received_message = entrada.readline(); system.out.println(received_message); entrada.close(); output.close(); } socket_connected.close(); } catch (ioexception excepcion) { system.out.println(excepcion); } }
client-side, flush output stream ?
when closing connection, remaining data flushed before that, if there enough "waiting" data sent.
Comments
Post a Comment