如果我殺了套接字服務器過程中,我的客戶端的Socket過程中沒有收到任何錯誤,它會繼續循環下去以下代碼:java的socket服務器,客戶端檢測到服務器已經死亡
public void run() {
while(readData) {
String inputLine = null;
try {
while((inputLine = m_inputStream.readLine()) != null) {
//do stuff
}
} catch (IOException e) {
readData = false;
}
}
}
我怎樣才能檢測到套接字服務器消失並終止循環?
因此,如果連接關閉,流將僅返回null? – anio 2009-07-20 22:40:31