Search in sources :

Example 1 with DatagramSessionConfig

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

Example 2 with DatagramSessionConfig

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