[英]Socket and SwingWorker doesn't work after closing the connection
我正在运行一个TCP / IP套接字,该套接字发送SOAP消息,然后获取响应,然后读取它。
问题在于这种情况:起初一切都很好,我发送了一条消息,然后使用swingworker得到了响应。 如果我关闭插座,然后尝试再次连接,我会通过布尔值停止回转工人。 当我再次连接时,我让线程运行,但是当我发送SOAP消息时,套接字没有得到任何输出,但是当我当时进行调试并逐步执行代码时,得到了响应和输出! 怎么会这样呢?
这是我的代码:
protected Object doInBackground() throws Exception {
Integer result = 1;
while (true) {
if (startReading && !this.server.isSocketClosed()) {
// send the SOAP Message based on which message is selected
SendSOAPRequestMessage();
//Thread.sleep(5);
String responseMessage = null;
try {
// get the response from the client/server
responseMessage = Utils.convertStreamToString(this.server);
System.out.println(responseMessage);
// give the message without the header + and check the content length and if the header is corrupted
fullMsg = decoder.DecodeSoapHeader(new String(responseMessage.getBytes("UTF-8")));
} catch (Exception ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.