网络不可达?

时间:2012-04-17 11:44:46

标签: java sockets exception

我想运行一个cyc(opencyc)Java类,但是当我运行这个类时,我收到一个错误,提到网络无法访问。我正在研究NetBeans 7.0和opencyc 2.0 win 32版本。我使用localhost(127.0.0.1)进行测试。错误如下。

Network is unreachable: connect
java.net.SocketException: Network is unreachable: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at org.opencyc.api.CycConnection.initializeApiConnections(CycConnection.java:223)
at org.opencyc.api.CycConnection.<init>(CycConnection.java:199)
at org.opencyc.api.CycAccess.<init>(CycAccess.java:121)
at org.opencyc.api.CycAccess.<init>(CycAccess.java:61)
at org.opencyc.api.ApiDemo.<init>(ApiDemo.java:50)
at org.opencyc.api.ApiDemo.main(ApiDemo.java:147)
Exception in thread "main" java.lang.NullPointerException
at org.opencyc.api.ApiDemo.<init>(ApiDemo.java:56)
at org.opencyc.api.ApiDemo.main(ApiDemo.java:147)
Interruption while waiting Cyc connection establishment, closing sockets
Exception in thread "Thread-1" java.lang.NullPointerException
at org.opencyc.api.CycConnection$TaskProcessorBinaryResponseHandler.access$002(CycConnection.java:988)
at org.opencyc.api.CycConnection.close(CycConnection.java:268)
at org.opencyc.api.CycConnection$ConnectionTimer.run(CycConnection.java:1351)

为什么会这样?我怎样才能连接到cyc?

2 个答案:

答案 0 :(得分:3)

问题是您的网络设置不允许您连接到本机。这不是Java问题。

ping {hostname}

直到这个工作,你无法在java中解决这个问题。

答案 1 :(得分:0)

如果您拥有相同的版本,它会尝试使用

定义的主机名和端口建立与Cyc映像的连接

CycConnection.DEFAULT_HOSTNAME
CycConnection.DEFAULT_BASE_PORT

您可以通过评估Cyc图像中的以下内容来找到要使用的正确值:

(get-machine-name)
*BASE-TCP-PORT*

希望这适合你。