0

I'm getting java.net.SocketException in the portion of code with try-catch IOException with no output of errors. SocketException is a successor of IOException so why?

try {
        Socket net = new Socket(TARGET, PORT);
        sendRawLine("GET / HTTP/1.1", net);
        sendRawLine("request", net);
        net.close();
    } catch (IOException e) {
        // System.out.println(e);
    }

java.net.SocketException: Connection reset
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
    at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
    at java.io.BufferedWriter.flush(BufferedWriter.java:254)
    at com.Joorvish.sendRawLine(Joorvish.java:125)
    at com.Joorvish.createSockets(Joorvish.java:99)
    at com.Lorento.run(Lorento.java:15)
    at java.lang.Thread.run(Thread.java:744)
java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
    at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
    at java.io.BufferedWriter.flush(BufferedWriter.java:254)
    at com.Joorvish.sendRawLine(Joorvish.java:125)
    at com.Joorvish.createSockets(Joorvish.java:100)
    at com.Lorento.run(Lorento.java:15)
    at java.lang.Thread.run(Thread.java:744)
7
  • Very simple. For why you need to read a liner here docs.oracle.com/javase/7/docs/api/java/net/SocketException.html if you need further help paste your code and tell us what you did and what are you expecting? Commented Oct 28, 2014 at 7:30
  • @chiastic-security line 15 is just exucutes a method with this code Commented Oct 28, 2014 at 8:10
  • 1
    at com.Joorvish.sendRawLine(Joorvish.java:125) at com.Joorvish.createSockets(Joorvish.java:99) This makes me suspect that sendRawLine is somehow used wrongly. Do you have some Docu about that method? Commented Oct 28, 2014 at 8:17
  • 2
    You need to post the whole of the method that this code appears in, along with its signature, and also line 15 that invokes it. Commented Oct 28, 2014 at 8:18
  • @Andy So you need to post the code of sendRawLine() for evaluation. Surely this is obvious? and the request for the code? and the stack trace? How exactly do you expect people to help you here? Magic? Commented Oct 28, 2014 at 8:44

1 Answer 1

1

java.net.SocketException: Broken pipe

This means you've written to a connection that has already been closed by the peer. The reason for that is almost certainly the invalid HTML that you appear to be writing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.