nio sockets + SetTcpNoDelay Exception...

K

Kam

Hi,

I use Nio sockets in a production projet for a while, without a single
problem.

Today, without having made any change to the code, I had the bad surprise to
see the following exception in my logs :

java.lang.ClassCastException
at sun.nio.ch.OptionAdaptor.<init>(OptionAdaptor.java:27)
at sun.nio.ch.SocketAdaptor.opts(SocketAdaptor.java:253)
at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:258)
at aks.net.AKSAcceptDaemon.run(AKSAcceptDaemon.java:135)

My code looks like : (file AKSAcceptDaemon.java)

Selector m_acceptSelector ;

... // selector initialisation

while (m_bRunning)
{
Set readyKeys ;
Iterator it ;
SelectionKey sk ;
ServerSocketChannel ssc ;
SocketChannel client;

while ( m_acceptSelector.select() > 0)
{
readyKeys = m_acceptSelector.selectedKeys();
it = readyKeys.iterator();

// Walk through the ready keys collection and process
date requests.
while (it.hasNext())
{
sk = (SelectionKey)it.next();
it.remove();

if (sk.isAcceptable())
{
ssc = (ServerSocketChannel)sk.channel();
client = ssc.accept();
client.configureBlocking(false) ;
// HERE IS THE GUILTY LINE
client.socket().setTcpNoDelay(false);
// HERE ENDS THE GUILTY LINE
client.socket().setKeepAlive(false);
m_engine.addNewClient(client) ;
}
}
}
}
}

Does someone see what can be the reason of this ?
I made a search on newsgroups, but didnt' found any answer.

Thanks in advance,

Cam

PS : sorry for my crap english : I'm french and frenchies have never been so
good at foreign languages :p
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top