diff options
Diffstat (limited to 'libjava/java/net/Socket.java')
-rw-r--r-- | libjava/java/net/Socket.java | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java index 7070838..cd3b5ec 100644 --- a/libjava/java/net/Socket.java +++ b/libjava/java/net/Socket.java @@ -291,16 +291,59 @@ public class Socket if (sm != null) sm.checkConnect(raddr.getHostName(), rport); + // create socket impl.create(stream); // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port, // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as // that default. JDK 1.2 doc infers not to do a bind. + + // bind/connect to address/port if (laddr != null) - impl.bind(laddr, lport); + { + try + { + impl.bind(laddr, lport); + } + catch (IOException exception) + { + impl.close(); + throw exception; + } + catch (RuntimeException exception) + { + impl.close(); + throw exception; + } + catch (Error error) + { + impl.close(); + throw error; + } + } if (raddr != null) - impl.connect(raddr, rport); + { + try + { + impl.connect(raddr, rport); + } + catch (IOException exception) + { + impl.close(); + throw exception; + } + catch (RuntimeException exception) + { + impl.close(); + throw exception; + } + catch (Error error) + { + impl.close(); + throw error; + } + } } /** |