Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Socket operation on nonsocket: sun.nio.ch.Net.setIntOption

843790Nov 5 2008 — edited Feb 2 2009
I'm having a apparently random problem when calling setTcpNoDelay() on a Socket object from a SocketChannel. One of my servers was getting flooded with connections from one IP address, and these exceptions kept getting thrown:
[LoginAuthentication-986]Accepting connection from 72.69.198.152
java.net.SocketException: Socket operation on nonsocket: sun.nio.ch.Net.setIntOption
        at sun.nio.ch.Net.setIntOption0(Native Method)
        at sun.nio.ch.Net.setIntOption(Net.java:154)
        at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:406)
        at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
        at sun.nio.ch.SocketOptsImpl$IP$TCP.noDelay(SocketOptsImpl.java:284)
        at sun.nio.ch.OptionAdaptor.setTcpNoDelay(OptionAdaptor.java:48)
        at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:268)
        at LoginAuthentication.handleLogin(LoginAuthentication.java:232)
        at net.allgofree.SharedBlitzIO.Authentication.Authenticator.updateAction(Authenticator.java:110)
        at net.allgofree.Updater.Updater.doUpdating(Updater.java:114)
        at server.main(server.java:366)
[LoginAuthentication-986]Login failed:java.net.SocketException: Socket operation on nonsocket: sun.nio.ch.Net.setIntOption
Here is the code that is generating the exception:
                    debug("Connection accepted from " + connectionStream.getInetAddress().getHostAddress());
                    connectionStream.getSocket().setTcpNoDelay(true);
                    waitForBytes(1);
In this case getSocket() is getting the Socket object from java.nio.channels.SocketChannel.socket().
Does anyone know what is causing this or how to fix it?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2009
Added on Nov 5 2008
3 comments
2,973 views