Fixed issue: NETTY-163 OioDatagramChannel.connect() hangs if called on a bound channel

* Set SO_TIMEOUT of DatagramSocket to 100ms
This commit is contained in:
Trustin Lee 2009-06-01 04:17:10 +00:00
parent ffe2831502
commit 151bf08095

View File

@ -30,6 +30,7 @@ import java.net.InetSocketAddress;
import java.net.MulticastSocket; import java.net.MulticastSocket;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.SocketException;
import org.jboss.netty.channel.AbstractChannel; import org.jboss.netty.channel.AbstractChannel;
import org.jboss.netty.channel.ChannelException; import org.jboss.netty.channel.ChannelException;
@ -68,6 +69,13 @@ final class OioDatagramChannel extends AbstractChannel
} catch (IOException e) { } catch (IOException e) {
throw new ChannelException("Failed to open a datagram socket.", e); throw new ChannelException("Failed to open a datagram socket.", e);
} }
try {
socket.setSoTimeout(10);
} catch (SocketException e) {
throw new ChannelException(
"Failed to configure the datagram socket timeout.", e);
}
config = new DefaultDatagramChannelConfig(socket); config = new DefaultDatagramChannelConfig(socket);
fireChannelOpen(this); fireChannelOpen(this);