Search in sources :

Example 1 with DatagramAcceptor

use of org.apache.mina.transport.socket.DatagramAcceptor 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();
}
Also used : UdpTransport(org.apache.directory.server.protocol.shared.transport.UdpTransport) DatagramAcceptor(org.apache.mina.transport.socket.DatagramAcceptor) InetSocketAddress(java.net.InetSocketAddress) DatagramSessionConfig(org.apache.mina.transport.socket.DatagramSessionConfig) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) DnsProtocolHandler(org.apache.directory.server.dns.protocol.DnsProtocolHandler) DnsException(org.apache.directory.server.dns.DnsException) IOException(java.io.IOException) IoSession(org.apache.mina.core.session.IoSession)

Aggregations

IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 DnsException (org.apache.directory.server.dns.DnsException)1 DnsProtocolHandler (org.apache.directory.server.dns.protocol.DnsProtocolHandler)1 UdpTransport (org.apache.directory.server.protocol.shared.transport.UdpTransport)1 IoSession (org.apache.mina.core.session.IoSession)1 ProtocolCodecFilter (org.apache.mina.filter.codec.ProtocolCodecFilter)1 DatagramAcceptor (org.apache.mina.transport.socket.DatagramAcceptor)1 DatagramSessionConfig (org.apache.mina.transport.socket.DatagramSessionConfig)1