java socket InputStream hangs/blocks on both client and server

前端 未结 2 758
春和景丽
春和景丽 2021-01-06 03:10

Hi, all

I am recently working on a tiny program aimed to close the browser remotely. The basic procedures are as follow:
Server side:

<
2条回答
  •  春和景丽
    2021-01-06 03:55

    Your socket reading code is reading until EOF. you will not receive EOF until you close the socket. hence, your code never proceeds.

    if you only want to send a single command on the socket connection, then close the OutputStream after writing the command (using Socket.shutdownOutput()).

    If you want to send multiple commands on a single socket connection, then you will need to come up with a way of delimiting each command (simple example here).

提交回复
热议问题