From 20e75710c971a02b5535dbe3029e6b08a97109f7 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 8 Jan 2018 14:00:31 +0000 Subject: [PATCH] tcpclient: enable crypto : raise an exception in case of error git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4023 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- tcpclient.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tcpclient.php b/tcpclient.php index 830bb6d..d92705f 100644 --- a/tcpclient.php +++ b/tcpclient.php @@ -159,7 +159,13 @@ class tcpclient )); stream_set_blocking ($this->socket, true); stream_context_set_option ($this->socket, $options); - return stream_socket_enable_crypto ($this->socket, !!$val, $cryptoMethod); + ini_set("track_errors", 1); + $rc = @stream_socket_enable_crypto ($this->socket, !!$val, $cryptoMethod); + ini_set("track_errors", 0); + if ($rc === false) + throw new \Exception ("Can not enable crypto to '$this->ipOrName' : ". + substr (strrchr ($php_errormsg, ":"), 1), 500); + return $rc; } /** Send a data to the server.