我有以下代码:
ServerSocket ss = new ServerSocket(2351);
Socket s = ss.accept();
InputStreamReader in = new InputStreamReader(s.getInputStream());
writer = new PrintWriter(s.getOutputStream());
writer.flush();
cbuf = new char[buf_length];
in.read(cbuf);
inputLine = new String(cbuf);
我连续四次发送到我的服务器,当我调试上面的代码时,它正确运行了三次。另一次,以下是从套接字读取的我的 inputLine:
POST /record HTTP/1.1
Content-type: application/soap+xml;charset="utf-8";action=""
Accept: application/soap+xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.5-b03-
Host: localhost:2351
Connection: keep-alive
Content-Length: 2197
内容只是 2197 个空格,而不是 2197 个长度的内容。它真的很奇怪,我被困住了。任何帮助表示赞赏。谢谢。