Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/fsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
struct timeval tv;
char *hashkey = NULL;
php_stream *stream = NULL;
int err;
int err = 0;
char *hostname = NULL;
size_t hostname_len;
zend_string *errstr = NULL;
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/streamsfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ PHP_FUNCTION(stream_socket_client)
struct timeval tv;
char *hashkey = NULL;
php_stream *stream = NULL;
int err;
int err = 0;
zend_long flags = PHP_STREAM_CLIENT_CONNECT;
zend_string *errstr = NULL;
php_stream_context *context = NULL;
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/network/fsockopen_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ $errno = null;
$errstr = null;
$timeout = 1.5;
var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) );
var_dump($errno);
var_dump($errstr);

echo "Done";
Expand All @@ -37,5 +38,6 @@ string(%d) "%a"

Warning: fsockopen(): Unable to connect to invalid://127.0.0.1:31337 (Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?) in %s on line %d
bool(false)
int(0)
string(100) "Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?"
Done
27 changes: 27 additions & 0 deletions ext/standard/tests/network/stream_socket_client_error.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Test stream_socket_client() function : error conditions
--FILE--
<?php
echo "*** Testing stream_socket_client() : basic error conditions ***\n";

echo "\n-- Attempting to connect using an invalid protocol --\n";
$address = 'invalid://127.0.0.1:31337';
$errno = null;
$errstr = null;
$timeout = 1.5;
var_dump( stream_socket_client($address, $errno, $errstr, $timeout) );
var_dump($errno);
var_dump($errstr);

echo "Done";
?>
--EXPECTF--
*** Testing stream_socket_client() : basic error conditions ***

-- Attempting to connect using an invalid protocol --

Warning: stream_socket_client(): Unable to connect to invalid://127.0.0.1:31337 (Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?) in %s on line %d
bool(false)
int(0)
string(100) "Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?"
Done
Loading