B
bengali
Hi,
i have a client application that connects to remote servers via tcp.
Connections are made in threads and i would like them to be
interruptible, i mean that client socket should not block and if they
receive an interrupt signal they should quit.
I have seen that java nio allows to create such non-blocking sockets.
SocketChannel sChannel = SocketChannel.open();
sChannel.configureBlocking(false);
Socket mySocket = sChannel.socket();
My problem is that sockets are created from third-party libraries (JNDI
and JMX) and i don't even manipulate sockets.
But the Socket class has a setSocketImplFactory(SocketImplFactory
factory) method which I could call at the beginning of my application
to set it a SocketImplFactory that would in turn return non-blocking
SocketImpl.
I have searched the Web and I haven't found anyone doing such things.
The SocketImpl class has a lot of abstract methods and i am reluctant
to extend it (lack of time).
Does anyone know if a non-blocking SocketImplFactory exists ?
Thanks,
Luc
i have a client application that connects to remote servers via tcp.
Connections are made in threads and i would like them to be
interruptible, i mean that client socket should not block and if they
receive an interrupt signal they should quit.
I have seen that java nio allows to create such non-blocking sockets.
SocketChannel sChannel = SocketChannel.open();
sChannel.configureBlocking(false);
Socket mySocket = sChannel.socket();
My problem is that sockets are created from third-party libraries (JNDI
and JMX) and i don't even manipulate sockets.
But the Socket class has a setSocketImplFactory(SocketImplFactory
factory) method which I could call at the beginning of my application
to set it a SocketImplFactory that would in turn return non-blocking
SocketImpl.
I have searched the Web and I haven't found anyone doing such things.
The SocketImpl class has a lot of abstract methods and i am reluctant
to extend it (lack of time).
Does anyone know if a non-blocking SocketImplFactory exists ?
Thanks,
Luc