-2
我們已經構建了一個系統適配器(客戶端)和一個SUT(服務器)以便通過套接字在它們之間發送字符串消息。我的意圖是做測試用例。 客戶端發送一個命令,sut會做一些事情併發送響應。 一切都做得很好,但被送到第四響應後,通過在5日已被髮送的時候,我遇到了以下問題:客戶端服務器套接字通信
java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at Interface.run(Interface.java:131)
at Interface.createAndShowGUI(Interface.java:382) //gui elements
at Interface.access$0(Interface.java:378) //gui elements
at Interface$1.run(Interface.java:392) //gui elements
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
do {
message = (String) in.readObject();
System.out.println("client-from server>" + message);
if (message.contains("endTC")) {
stateLabel.setText("OpenAndUnlocked");
}
else if (message.contains("closed")) {
b1.doClick();
}
else if (message.contains("lock")) {
b2.doClick();
} else if (message.contains("open")) {
b3.doClick();
} else if (message.contains("unlock")) {
b4.doClick();
} else if (message.contains("exit")) {
sendMessage("Exiting");
}
} while (!message.equals("end")); //always loop
這牆文是一個問題? :\ – theBigChalk
你已經省略了相關的代碼 - 錯誤將涉及到'Interface.run'的定義,因爲它顯然期望有一個對象,但是找到流的結束。 –
可以幫助也看到發送代碼...顯然另一方關閉了連接。 –