You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Adam Fisk <a...@lastbamboo.org> on 2007/07/07 00:47:34 UTC

UDP IoSession getLocalAddress

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?

Thanks a lot!

-Adam

Re: UDP IoSession getLocalAddress

Posted by Adam Fisk <a...@lastbamboo.org>.
I forgot to mention this is with 1.1.0.  Thanks.  -Adam

On 7/6/07, Adam Fisk <a...@lastbamboo.org> 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?
>
> Thanks a lot!
>
> -Adam
>
>

Re: UDP IoSession getLocalAddress

Posted by Adam Fisk <a...@lastbamboo.org>.
I just added a detailed bug.  I believe it's only relevant for connectors,
but I haven't verified that.

-Adam


On 7/8/07, Adam Fisk <a...@lastbamboo.org> wrote:
>
> 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 <tr...@gmail.com>>
> wrote:
> >
> > On 7/7/07, Adam Fisk <a@...@lastbamboo.org>>
> > 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
> >
>
>

Re: UDP IoSession getLocalAddress

Posted by Adam Fisk <a...@lastbamboo.org>.
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 <tr...@gmail.com> wrote:
>
> On 7/7/07, Adam Fisk <a...@lastbamboo.org> 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
>

Re: UDP IoSession getLocalAddress

Posted by Trustin Lee <tr...@gmail.com>.
On 7/7/07, Adam Fisk <a...@lastbamboo.org> 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