/[classpath]/classpath/java/net/Socket.java
ViewVC logotype

Diff of /classpath/java/net/Socket.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34 by mkoch, Tue Dec 2 09:48:12 2003 UTC revision 1.35 by mkoch, Tue Dec 2 10:04:08 2003 UTC
# Line 347  public class Socket Line 347  public class Socket
347      try      try
348        {        {
349          getImpl().bind (tmp.getAddress(), tmp.getPort());          getImpl().bind (tmp.getAddress(), tmp.getPort());
         bound = true;  
350        }        }
351      catch (IOException exception)      catch (IOException exception)
352        {        {
# Line 444  public class Socket Line 443  public class Socket
443     */     */
444    public InetAddress getInetAddress ()    public InetAddress getInetAddress ()
445    {    {
446      return getImpl().getInetAddress();      try
447          {
448            return getImpl().getInetAddress();
449          }
450        catch (SocketException e)
451          {
452            // This cannot happen as we are connected.
453          }
454    
455        return null;
456    }    }
457    
458    /**    /**
# Line 458  public class Socket Line 466  public class Socket
466    public InetAddress getLocalAddress ()    public InetAddress getLocalAddress ()
467    {    {
468      InetAddress addr = null;      InetAddress addr = null;
469        
470      try      try
471        {        {
472          addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);          addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
# Line 490  public class Socket Line 499  public class Socket
499     */     */
500    public int getPort ()    public int getPort ()
501    {    {
502      if (impl != null)      try
503        return getImpl().getPort();        {
504            if (getImpl() != null)
505              return getImpl().getPort();
506          }
507        catch (SocketException e)
508          {
509            // This cannot happen as we are connected.
510          }
511    
512      return -1;      return -1;
513    }    }
# Line 504  public class Socket Line 520  public class Socket
520     */     */
521    public int getLocalPort ()    public int getLocalPort ()
522    {    {
523      if (impl != null)      try
524        return getImpl().getLocalPort();        {
525            if (getImpl() != null)
526              return getImpl().getLocalPort();
527          }
528        catch (SocketException e)
529          {
530            // This cannot happen as we are bound.
531          }
532    
533      return -1;      return -1;
534    }    }
# Line 518  public class Socket Line 541  public class Socket
541     */     */
542    public SocketAddress getLocalSocketAddress()    public SocketAddress getLocalSocketAddress()
543    {    {
544      InetAddress addr = getLocalAddress ();      if (!isBound())
   
     if (addr == null)  
545        return null;        return null;
546            
547      return new InetSocketAddress (addr, getImpl().getLocalPort());      InetAddress addr = getLocalAddress ();
548    
549        try
550          {
551            return new InetSocketAddress (addr, getImpl().getLocalPort());
552          }
553        catch (SocketException e)
554          {
555            // This cannot happen as we are bound.
556            return null;
557          }
558    }    }
559    
560    /**    /**
# Line 537  public class Socket Line 568  public class Socket
568      if (!isConnected ())      if (!isConnected ())
569        return null;        return null;
570    
571      return new InetSocketAddress(getImpl().getInetAddress (), getImpl().getPort ());      try
572          {
573            return new InetSocketAddress (getImpl().getInetAddress (), getImpl().getPort ());
574          }
575        catch (SocketException e)
576          {
577            // This cannot happen as we are connected.
578            return null;
579          }
580    }    }
581    
582    /**    /**
# Line 1068  public class Socket Line 1107  public class Socket
1107     */     */
1108    public boolean isConnected ()    public boolean isConnected ()
1109    {    {
1110      return getImpl().getInetAddress () != null;      try
1111          {
1112            return getImpl().getInetAddress () != null;
1113          }
1114        catch (SocketException e)
1115          {
1116            return false;
1117          }
1118    }    }
1119    
1120    /**    /**

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26