Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use readline without and EOF character java
    primarykey
    data
    text
    <p>i am trying to implement a simple server application in java.</p> <p>all it does is read in a message on the tcp/ip and stores it as a string this is my code.</p> <pre><code> try{ in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); } catch (IOException e) { System.out.println("cannot open input buffer"); System.exit(-1); } clientSocket.setSoTimeout(5000); //read first bit of message message = in.readLine(); System.out.println(message); //as message is an undefined length we need to loop and check for the springer miller //end mark /Request while(message.contains("/Request") == false ) { try { message = in.readLine(); System.out.println(message); } catch (IOException e) { System.out.println("cannot open input buffer"); System.exit(-1); } } //reply out.println(outputLine); </code></pre> <p>the problem i am having is that the message does not appear to have an EOF. it is another companies protocol i am translating into mine, thats the purpose of the program so i cannot add a EOF to the message </p> <p>the information a get if i run the program is:</p> <pre><code>POST / HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: http://htng.org/1.1/Listener.Wsdl#ReceiveMessageAsync User-Agent: Java/1.6.0_24 Host: 192.168.0.32:8080 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive Content-Length: 3009 </code></pre> <p>then it hangs when it should read the message body.</p> <p>i have never used java in my life before and do not want to write a binary socket readed to detect my own EOF.</p> <p>is there a way to read for x seconds and then return</p> <p>thank you for any help.</p> <p>P.S have already successfully built the program in C++ but need to port in to java because destined machine is unknown. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload