Is there a way to read the inputstream for a specific amount of time?

后端 未结 4 1912
清歌不尽
清歌不尽 2021-01-19 18:18

I\'ve a situation where a thread opens a telnet connection to a target m/c and reads the data from a program which spits out the all the data in its buffer. After all the da

4条回答
  •  鱼传尺愫
    2021-01-19 18:50

    Use another thread to close the connection after 15 mins. Alternatively, you could check after each read if 15mins have passed and then simply stop reading and cleanup the connection, but this would only work if you're sure the remote server will continue to send data (if it doesn't the read will block indefinitely).

提交回复
热议问题