[ http://issues.apache.org/jira/browse/DIRMINA-208?page=comments#action_12442166 ] Jörg Henne commented on DIRMINA-208: ------------------------------------
[[ Old comment, sent by email on Mon, 03 Jul 2006 12:43:15 +0200 ]] Trustin, No worries! I saw your message on the list and can fully understand you having quite a few other priorities. All the best wishes for you and your dog and thanks for all the effort you put into this project. Joerg Henne > Allow datagrams to be directed to a specific destination on a per-datagram > instead of a per-session basis. > ---------------------------------------------------------------------------------------------------------- > > Key: DIRMINA-208 > URL: http://issues.apache.org/jira/browse/DIRMINA-208 > Project: Directory MINA > Issue Type: Wish > Affects Versions: 0.9.3 > Reporter: Jörg Henne > Assigned To: Trustin Lee > Fix For: 0.9.5 > > Attachments: pcf.patch > > > [this is a copy of a message I sent to the mailing-list a few days ago] > A few weeks ago I started to work on the DS DHCP server. Work has progressed > so far that clients can successfully register IP addresses with the server > and all, although the code is still unfit for general consumption. > Ir order to implement the DHCP functionality, however, it was necessary to > apply a minor patch to the MINA code base. The patch is necessitated by the > fact that packets which are received via broadcast from a DHCP client don't > have a proper source address. As a consequence, the reply messages must also > be broadcast (or, in some cases sent by unicast to a different address). The > existing code created a new MINA IoSession per message in order to handle > this case, causing quite a lot of overhead and, worse, a new thread which > lingered even after it was done. > In order to do away with the overhead, I introduced a special session > attribute which allows me to re-direct a message while it is sent like this: > InetSocketAddress isa = determineMessageDestination( request, > reply ); > session.setAttribute( "destination", isa ); > session.write( reply ); > This property is used in DatagramAcceptorDelegate.flush(DatagramSessionImpl) > to override the message destination address like this: > ... > if ( !key.isValid() ) > { > continue; > } > // HACK: allow destination to be overridden using session > attribute. > SocketAddress destination = session.getRemoteAddress(); > Object d = session.getAttribute( "destination" ); > if ( null != d && d instanceof SocketAddress ) > destination = ( SocketAddress ) d; > int writtenBytes = ch.send( buf.buf(), destination ); > ... > I am not too happy with this hack, but it was easy and worked. I you could > come up with a more general and elegant solution, I'd be more than happy. > Joerg Henne -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira