summaryrefslogtreecommitdiff
path: root/java/net
diff options
context:
space:
mode:
authorAaron M. Renn <arenn@urbanophile.com>1998-06-10 00:28:41 +0000
committerAaron M. Renn <arenn@urbanophile.com>1998-06-10 00:28:41 +0000
commit4d7dae1f16248d9e0d12e3e2765c91faeaee3c7d (patch)
treee8114e446853dc572fc814bb5fdec10970c87692 /java/net
parente1e4758f89b1f8916e03f7f7692b069e4aa62774 (diff)
downloadclasspath-4d7dae1f16248d9e0d12e3e2765c91faeaee3c7d.tar.gz
Added finalize method
Diffstat (limited to 'java/net')
-rw-r--r--java/net/DatagramSocket.java11
-rw-r--r--java/net/ServerSocket.java12
-rw-r--r--java/net/Socket.java11
3 files changed, 34 insertions, 0 deletions
diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java
index 3fef08592..60e73c6ca 100644
--- a/java/net/DatagramSocket.java
+++ b/java/net/DatagramSocket.java
@@ -126,6 +126,17 @@ DatagramSocket(int port, InetAddress addr) throws SocketException
/*************************************************************************/
/**
+ * Ensure that the socket is closed when this object is garbage collected
+ */
+protected void
+finalize() throws IOException
+{
+ close();
+}
+
+/*************************************************************************/
+
+/**
* Closes this socket.
*/
public synchronized void
diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java
index 1c4a0d4d8..715c2cc61 100644
--- a/java/net/ServerSocket.java
+++ b/java/net/ServerSocket.java
@@ -229,6 +229,18 @@ accept() throws IOException
/*************************************************************************/
/**
+ * Ensure that this socket gets closed when the object is garbage
+ * collected.
+ */
+protected void
+finalize() throws IOException
+{
+ close();
+}
+
+/*************************************************************************/
+
+/**
* Closes this socket and stops listening for connections
*
* @exception IOException If an error occurs
diff --git a/java/net/Socket.java b/java/net/Socket.java
index 6708232e9..ec390a3bd 100644
--- a/java/net/Socket.java
+++ b/java/net/Socket.java
@@ -297,6 +297,17 @@ Socket(InetAddress raddr, int rport, InetAddress laddr, int lport,
*/
/**
+ * This method closes the socket when this object is garbage collected
+ */
+protected void
+finalize() throws IOException
+{
+ close();
+}
+
+/*************************************************************************/
+
+/**
* Closes the socket.
*
* @exception IOException If an error occurs