From 143f596a09eb477adb10f7e710df0b4b97fa4115 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Fri, 2 May 2003 09:27:59 +0000 Subject: InetAddress.java: Merged class documentation with classpath. 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. From-SVN: r66376 --- 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 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; + } + } } /** -- cgit v1.1