2

Error receiving connection: java.net.SocketException: Invalid argument Exception in thread "Thread-698" java.lang.RuntimeException: Did not establish input/output at Handin2.ConnectionHandlerImpl.run(ConnectionHandlerImpl.java:124) at java.lang.Thread.run(Thread.java:722)

I have been searching a lot on this exception. Everywhere it seems to be the conclusion that if you compile with the JVM option -Djava.net.preferIPv4Stack=true it will solve the problem. It doesn't for me though. I am running IntelliJ and trying to implement a Chord system with Sockets and Threads. This is where the above mentioned exception is caught and thrown:

if(this.remote == null || this.node == null) {
    throw new RuntimeException("Connection handler has not been properly "
                + "initalialized");
}
try{
    if(this.out == null) {
      this.out = new ObjectOutputStream(remote.getOutputStream());
    }
    if(this.in == null) {
      this.in = new ObjectInputStream(remote.getInputStream());
    }
} catch(IOException e) {
      System.out.println("Trying to make input/output for remote " + remote);
      System.err.println(node.getKey()/Constants.NORMALIZE_KEY+": Error receiving connection: " + e.toString());
      return false;
}

I don't know if more code snippets are needed in order to help, but I am simply lost on this exception since the solutions when searching are not helping at all.

Any hints on what triggers this error? The socket exception is caught by the given try-catch block as a special case of an IO exception

1
  • "java.lang.RuntimeException: Did not establish input/output at ..." This is not a Java exception. It is an application exception. It is meaningless without the underlying Java exception. In general it is poor practice to make up your own text when you get an exception. Use the text in the exception you caught. Commented Feb 18, 2013 at 9:03

1 Answer 1

2

if you compile with the JVM option -Djava.net.preferIPv4Stack=true it will solve the problem.

No. If you execute with that JVM option. Nothing to do with the compiler.

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.