V
V
Vadim Gush2014-04-21 19:23:19
Java
Vadim Gush, 2014-04-21 19:23:19

How to solve IP problem in Java?

This line of code gives an error

connection = new Socket(Inet4Address.getByName(ip), 5555);

Here is the error:
java.net.ConnectException: Connection refused: connect
  at java.net.DualStackPlainSocketImpl.connect0(Native Method)
  at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
  at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
  at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
  at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
  at java.net.PlainSocketImpl.connect(Unknown Source)
  at java.net.SocksSocketImpl.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at java.net.Socket.connect(Unknown Source)
  at java.net.Socket.<init>(Unknown Source)
  at java.net.Socket.<init>(Unknown Source)
  at core.Main.run(Main.java:58)
  at java.lang.Thread.run(Unknown Source)

If ip = "127.0.0.1" then everything works and the server calmly responds
If I write my ip, that is, ip = "95.84.36.178", then it gives an error

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2014-04-21
@VadimGu

Check if the regular firewall is enabled? Is there any anti-virus software that blocks either outgoing traffic from Java or incoming connections?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question