client有如下偽代碼:
try{
Socket ss = new Socket();
ss.connect(new InetSocketAddress(127.0.0.1, TCPServer.LISTEN_PORT), 4000);
ss.setSoTimeout(5000);
//dosomthing
InputStream is = ss.getInputStrean();
log.info("read start time:" + System.currentTimeMillis())
int r = is.read(....);
log.info("read start time:" + System.currentTimeMillis())
} catch(Exception e){
log.info("throw exception time:" + System.currentTimeMillis());
}
上面這樣的邏輯,ss.setSoTimeout(5000);把讀超時設置為5000ms,可經過測試read的時間也不過才619ms 就拋出了如題的異常?
添加回答
舉報
0/150
提交
取消