I am trying to write a code for a simple server, that receives messages from a client. The connection is succesful but once the server connects with the client the messages are not displayed on the screen. After I close the connection from the client side, the server receives all the messages in one go.

I need to receive the messages line by line because each line needs to de processed individually and in real time (I am using HMM for driver's actions recognition).

Could someone tell me what am I doing wrong?

Thanko you very 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);
    }
}   

```