It's just that IoSession.getLocalAddress doesn't actually return the local
address.  Rather, it returns the remote address!  Looking at the comment in
the code, though, it appears this is intentional, so I didn't consider
entering a bug.  I was mostly trying to figure out how to actually get the
local address, but I resorted to some reflection hackery to get the
underlying channel.

It actually seems like you'd have other issues for the comment I quoted to
be relevant, but I don't know the code well enough to say for sure.  Just
making the channel accessor public would allow a workaround, but that's not
ideal.

I'll enter a bug.

Thanks.

-Adam


On 7/7/07, Trustin Lee <[EMAIL PROTECTED]> wrote:

On 7/7/07, Adam Fisk <[EMAIL PROTECTED]> wrote:
> I noticed this chunk of code in the constructor for DatagramSessionImpl
> after realizing getLocalAddress didn't return the local address at all:
>
>        // We didn't set the localhost by calling getLocalSocketAddress()
to
> avoid
>        // the case that getLocalSocketAddress() returns IPv6 address
while
>        // serviceAddress represents the same address in IPv4.
>        this.localAddress = this.serviceAddress = serviceAddress;
>
> Is there any way I can get the local address for a UDP session without
> compiling my own version?

Do you have a fix for the problem you are describing?  Then please let
us know.  I actually didn't understand what the problem here is.
Under what condition does getLocalAddress() return null?

Thanks for the report,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to