BufferedReader readLine method hangs and block program

前端 未结 3 1227
说谎
说谎 2020-12-18 13:03

I\'m trying to learn sockets using Java and I sucessfully sent data to a ServerSocket running in my own machine. When I try to read from this socket using readline (so I can

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 14:03

    cli.ostream.writeUTF("Teste");
    

    Shouldn't this be containing a new line? Otherwise read method will be waiting for new line I think.

    Also as suggested you can try flushing the ostream after writing to it.

提交回复
热议问题