diff options
author | Michael Koch <konqueror@gmx.de> | 2003-05-02 09:27:59 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-05-02 09:27:59 +0000 |
commit | 143f596a09eb477adb10f7e710df0b4b97fa4115 (patch) | |
tree | d395dadb3026a885728844a608ac376f88c1f984 /libjava/java/net | |
parent | 9ab94a932c3cd105735460d62dc980e41d1a2e27 (diff) | |
download | gcc-143f596a09eb477adb10f7e710df0b4b97fa4115.zip gcc-143f596a09eb477adb10f7e710df0b4b97fa4115.tar.gz gcc-143f596a09eb477adb10f7e710df0b4b97fa4115.tar.bz2 |
InetAddress.java: Merged class documentation with classpath.
2003-05-02 Michael Koch <konqueror@gmx.de>
* 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
Diffstat (limited to 'libjava/java/net')
-rw-r--r-- | libjava/java/net/InetAddress.java | 20 | ||||
-rw-r--r-- | libjava/java/net/JarURLConnection.java | 16 | ||||
-rw-r--r-- | libjava/java/net/ServerSocket.java | 45 | ||||
-rw-r--r-- | libjava/java/net/Socket.java | 47 | ||||
-rw-r--r-- | libjava/java/net/URL.java | 4 |
5 files changed, 114 insertions, 18 deletions
diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java index 4cbcb1a..34d4ad1 100644 --- a/libjava/java/net/InetAddress.java +++ b/libjava/java/net/InetAddress.java @@ -44,20 +44,28 @@ import java.io.IOException; import java.io.Serializable; import java.io.ObjectStreamException; -/** - * @author Per Bothner - * @date January 6, 1999. - */ - /* * Written using on-line Java Platform 1.2 API Specification, as well * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * (The latter turns out to have some errors ...) * Status: Believed complete and correct. + */ + +/** + * This class models an Internet address. It does not have a public + * constructor. Instead, new instances of this objects are created + * using the static methods getLocalHost(), getByName(), and + * getAllByName(). + * <p> + * This class fulfills the function of the C style functions gethostname(), + * gethostbyname(), and gethostbyaddr(). It resolves Internet DNS names + * into their corresponding numeric addresses and vice versa. + * + * @author Aaron M. Renn <arenn@urbanophile.com> + * @author Per Bothner * * @specnote This class is not final since JK 1.4 */ - public class InetAddress implements Serializable { // The Serialized Form specifies that an int 'address' is saved/restored. diff --git a/libjava/java/net/JarURLConnection.java b/libjava/java/net/JarURLConnection.java index ed74265..b8fcbf5 100644 --- a/libjava/java/net/JarURLConnection.java +++ b/libjava/java/net/JarURLConnection.java @@ -38,10 +38,16 @@ exception statement from your version. */ package java.net; -import java.net.*; -import java.io.*; -import java.util.jar.*; -import java.util.zip.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.IOException; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.Manifest; +import java.util.zip.ZipEntry; import java.util.Map; import java.util.Vector; import java.util.Hashtable; @@ -52,8 +58,6 @@ import java.security.cert.Certificate; * @since 1.2 * @date Aug 10, 1999. */ - - public abstract class JarURLConnection extends URLConnection { // three different ways to say the same thing diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java index 0285c12..2d04eac 100644 --- a/libjava/java/net/ServerSocket.java +++ b/libjava/java/net/ServerSocket.java @@ -164,9 +164,50 @@ public class ServerSocket if (bindAddr == null) bindAddr = InetAddress.ANY_IF; + // create socket impl.create(true); - impl.bind(bindAddr, port); - impl.listen(backlog); + + // bind to address/port + try + { + impl.bind(bindAddr, port); + } + catch (IOException exception) + { + impl.close(); + throw exception; + } + catch (RuntimeException exception) + { + impl.close(); + throw exception; + } + catch (Error error) + { + impl.close(); + throw error; + } + + // listen on socket + try + { + impl.listen(backlog); + } + catch (IOException exception) + { + impl.close(); + throw exception; + } + catch (RuntimeException exception) + { + impl.close(); + throw exception; + } + catch (Error error) + { + impl.close(); + throw error; + } } /** 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; + } + } } /** diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index 33e42ef..fd7428e 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -99,7 +99,7 @@ import java.util.StringTokenizer; * Please note that a protocol handler must be a subclass of * URLStreamHandler. * - * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Aaron M. Renn <arenn@urbanophile.com> * @author Warren Levy <warrenl@cygnus.com> * * @see URLStreamHandler @@ -720,7 +720,7 @@ public final class URL implements Serializable } private static synchronized URLStreamHandler - getURLStreamHandler(String protocol) + getURLStreamHandler (String protocol) { URLStreamHandler handler; |