commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [commit-cp] java.net.Socket#getLocalAddress() should return anylocal


From: Michael Koch
Subject: Re: [commit-cp] java.net.Socket#getLocalAddress() should return anylocal if not bound
Date: Tue, 14 Sep 2004 18:46:50 +0200
User-agent: KMail/1.6.2

On Tuesday 14 September 2004 18:15, Ito Kazumitsu wrote:
> Hi,
>
> As reported in
> http://www.kaffe.org/pipermail/kaffe/2004-September/099697.html I
> suggest java.net.Socket should be fixed.
>
> 2004-09-14  Ito Kazumitsu  <address@hidden>
>
>       * java/net/Socket.java(getLocalAddress()):
>       If the socket is not bound yet,
>       return InetAddress.ANY_IF rather than null.

Thanks for this report. 

Please send patches for review to address@hidden

> --- java/net/Socket.java.orig Mon Jul 26 21:13:57 2004
> +++ java/net/Socket.java      Tue Sep 14 14:15:51 2004
> @@ -479,7 +479,8 @@
>
>    /**
>     * Returns the local address to which this socket is bound.  If
> this socket -   * is not connected, then <code>null</code> is
> returned. +   * is not connected, then a wildcard address, for
> which isAnyLocalAddress() +   * is true, is returned.
>     *
>     * @return The local address
>     *
> @@ -487,21 +488,25 @@
>     */
>    public InetAddress getLocalAddress()
>    {
> -    if (! isBound())
> -      return null;
> -
>      InetAddress addr = null;
>
> -    try
> +    if (! isBound())
>        {
> -     addr = (InetAddress)
> getImpl().getOption(SocketOptions.SO_BINDADDR); +        addr =
> InetAddress.ANY_IF;
>        }
> -    catch (SocketException e)
> +    else
>        {
> -     // (hopefully) shouldn't happen
> -     // throw new java.lang.InternalError
> -     //      ("Error in PlainSocketImpl.getOption");
> -     return null;
> +        try
> +          {
> +         addr = (InetAddress)
> getImpl().getOption(SocketOptions.SO_BINDADDR); +          }
> +        catch (SocketException e)
> +          {
> +         // (hopefully) shouldn't happen
> +         // throw new java.lang.InternalError
> +         //      ("Error in PlainSocketImpl.getOption");
> +         return null;
> +          }
>        }
>
>      // FIXME: According to libgcj, checkConnect() is supposed to
> be called

I dont know why, but this patch somehow didnt apply cleanly to new 
checkout of classpath.

If you are okay with it I will commit the attached slightly edited 
patch.


Michael

Attachment: socket.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]