use of org.apache.mina.transport.socket.DatagramSessionConfig in project vert.x by eclipse.
the class FakeDNSServer method start.
@Override
public void start() throws IOException {
UdpTransport transport = new UdpTransport("127.0.0.1", port);
setTransports(transport);
acceptor = transport.getAcceptor();
acceptor.setHandler(new DnsProtocolHandler(this, store) {
@Override
public void sessionCreated(IoSession session) throws Exception {
// Use our own codec to support AAAA testing
session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
}
});
// Allow the port to be reused even if the socket is in TIME_WAIT state
((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
// Start the listener
acceptor.bind();
}
use of org.apache.mina.transport.socket.DatagramSessionConfig in project netty by netty.
the class TestDnsServer method start.
@Override
public void start() throws IOException {
InetSocketAddress address = new InetSocketAddress(NetUtil.LOCALHOST4, 0);
UdpTransport transport = new UdpTransport(address.getHostName(), address.getPort());
setTransports(transport);
DatagramAcceptor acceptor = transport.getAcceptor();
acceptor.setHandler(new DnsProtocolHandler(this, store) {
@Override
public void sessionCreated(IoSession session) throws Exception {
// USe our own codec to support AAAA testing
session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
}
});
((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
// Start the listener
acceptor.bind();
}
Aggregations