From 3f17e0689e06ffab85f41e5f9e9318f5cce51fe6 Mon Sep 17 00:00:00 2001 From: mkoch Date: Fri, 2 May 2003 09:27:59 +0000 Subject: 2003-05-02 Michael Koch * java/net/InetAddress.java: Merged class documentation with classpath. * java/net/JarURLConnection.java: Explicitely import all used classes. * java/net/URL.java: Reformatting. * java/net/ServerSocket.java, java/net/Socket.java: New versions from classpath. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66376 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/net/Socket.java | 47 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'libjava/java/net/Socket.java') diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java index 7070838c7e8..cd3b5ecb857 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; + } + } } /** -- cgit v1.2.3