diff --git a/src/Stream.php b/src/Stream.php index 507f135..e472366 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -66,6 +66,16 @@ public function __toString() } } + /** + * Close the socket when the object is destructed. + */ + public function __destruct() + { + if (is_resource($this->socket)) { + $this->close(); + } + } + /** * {@inheritdoc} */