简体   繁体   中英

socketChannel throws IOException with Permission Denied

A code that worked me for a while now on various platforms started to suddenly to fail, there were changed in the code but not in an area that related to this place.

The line of code that throws the exceptions is:

(SocketChannel) selectionKey.channel()).finishConnect()

And it throws:

java.net.SocketException: Permission denied: no further information

what may be the issue?

Some log lines that might show more info, it is a test code:

2016-12-04 22:50:10,585 [main] DEBUG Socket - Socket-Client-1-1
register to connect to address: 0.0.0.0/0.0.0.0:8080
2016-12-04 22:50:10,585 [main] DEBUG SocketSelector - Registering keys: OP_CONNECT (for Socket-Client-1-1)
2016-12-04 22:50:10,595 [main] DEBUG SocketSelector - Registered to: OP_CONNECT > 2016-12-04 22:50:10,595 [NetworkThread] DEBUG SocketSelector -Got selected keys
for channel (java.nio.channels.SocketChannel[connection-pending remote=0.0.0.0/0.0.0.0:8080])

The issue is that you are attempting to connect to 0.0.0.0, which is not a valid TCP target address. This causes EPERM for the reasons described in man connect .

Use 127.0.0.1 or a proper IP address.

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