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
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