You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Ashish <pa...@gmail.com> on 2008/11/28 11:36:42 UTC

Can a single socket be used for TCP/UDP [Was reading ApacheDS DNS implementation]

Was browsing ApacheDS DNS code and found this construct in
org.apache.directory.server.dns.DnsServer.java

public void start() throws IOException
    {
        RecordStore store = new JndiRecordStoreImpl(
getSearchBaseDn(), getSearchBaseDn(), getDirectoryService() );

        if ( getDatagramAcceptor() != null )
        {
            DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig();
            getDatagramAcceptor().bind( new InetSocketAddress(
getIpPort() ), new DnsProtocolHandler( this, store ), udpConfig );
        }

        if ( getSocketAcceptor() != null )
        {
            SocketAcceptorConfig tcpConfig = new SocketAcceptorConfig();
            tcpConfig.setDisconnectOnUnbind( false );
            tcpConfig.setReuseAddress( true );
            getSocketAcceptor().bind( new InetSocketAddress(
getIpPort() ), new DnsProtocolHandler( this, store ), tcpConfig );
        }

        LOG.info( "DSN service started." );
        System.out.println( "DSN service started." );
    }

Got these queries

Q1. Using this construct, will we be able to receive TCP as well as
UDP traffic on the same port? or I am missing something

Q2. ApacheDS DNS implementation uses per session FilterChain (set in
IoHandler), based on the session transport. Is the understanding
correct that IOFilterChains are per session?

Can't the DNS and other protocol implementation in ApacheDS projects
be made subproject(s) in Apache MINA?

-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog

My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Can a single socket be used for TCP/UDP [Was reading ApacheDS DNS implementation]

Posted by Emmanuel Lecharny <el...@gmail.com>.
Ashish wrote:
> Was browsing ApacheDS DNS code and found this construct in
> org.apache.directory.server.dns.DnsServer.java
>
> public void start() throws IOException
>     {
>         RecordStore store = new JndiRecordStoreImpl(
> getSearchBaseDn(), getSearchBaseDn(), getDirectoryService() );
>
>         if ( getDatagramAcceptor() != null )
>         {
>             DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig();
>             getDatagramAcceptor().bind( new InetSocketAddress(
> getIpPort() ), new DnsProtocolHandler( this, store ), udpConfig );
>         }
>
>         if ( getSocketAcceptor() != null )
>         {
>             SocketAcceptorConfig tcpConfig = new SocketAcceptorConfig();
>             tcpConfig.setDisconnectOnUnbind( false );
>             tcpConfig.setReuseAddress( true );
>             getSocketAcceptor().bind( new InetSocketAddress(
> getIpPort() ), new DnsProtocolHandler( this, store ), tcpConfig );
>         }
>
>         LOG.info( "DSN service started." );
>         System.out.println( "DSN service started." );
>     }
>
> Got these queries
>
> Q1. Using this construct, will we be able to receive TCP as well as
> UDP traffic on the same port? or I am missing something
>   
Yes you can ! DatagramSocket and tp Socket are different beasts.
> Q2. ApacheDS DNS implementation uses per session FilterChain (set in
> IoHandler), based on the session transport. Is the understanding
> correct that IOFilterChains are per session?
>   
All the chains are per session. If fact, they are copied from the 
generic definition of the chain. (it's not only the case for DNS, it's 
the way MINA  handles chains)
> Can't the DNS and other protocol implementation in ApacheDS projects
> be made subproject(s) in Apache MINA?
>   
Well, this is a possibility. Initially, as DNS requires some storage, it 
was based on ADS to provide such a storage. Also keep in mind that back 
in 2005 and up to 2007, MINA was an ADS's subproject...


-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org