![](/img/trans.png)
[英]Does closing the BufferedReader/PrintWriter close the socket connection?
[英]Socket programming PrintWriter does not produce output
我的服務器代碼如下:
writer = new PrintWriter(s.getOutputStream());
writer.flush();
writer.print("HTTP/1.1 200 OK\r\n");
writer.print("Content-Length: " + len + "\r\n");
writer.print("Content-Type: "+"application/soap+xml;charset=utf-8"+"\r\n\r\n");
writer.print(response);
writer.close();
變量響應是SOAP + XML。 我正在添加發送它所需的HTTP頭,它在某些情況下有效,但在大多數情況下,我的客戶端(SOAPUI)只是等待不生成的響應。 當我關閉客戶端時,我沒有在服務器端看到任何錯誤。
任何幫助表示贊賞。 謝謝。
“...關閉返回的OutputStream將關閉相關的套接字....”。
關閉PrintWriter將關閉OutputStream,然后關閉套接字。 只需刷新PrintWriter,不要關閉它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.