简体   繁体   中英

java.net.ConnectException: Connection refused: connect java nio

**java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect0(Native Method)
    at sun.nio.ch.Net.connect(Net.java:454)
    at sun.nio.ch.Net.connect(Net.java:446)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)

I have this exception when i use socketchannel between two pcs on the same local network strong text .. but when i use on the same PC is connects and send bytes without any exception..any help?

the error happens when calling connect(socketAddress);

    **socketChannel.connect(socketAddress);****

First check the connectivity between the two PCs by using ping from one machine using the IP

ping 192.168.x.x 

If the ping works, double check the firewall settings of both the PCs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM