quelqu'un sait s'il est possible de récupérer quelques informations d'erreur (comme getsockopt SO_ERROR en C) si un async connecter comme ce qui suit échoue BTW: je ne suis pas avec l'extension socket flux de cause fournissent une ssl wrapperchaîne d'erreur de socket get lorsque async connexion échoue
<?php
$ctx = stream_context_create();
stream_context_set_params($ctx, array("notification" => "stream_notification_callback"));
$destination = "tcp://92.247.12.242:8081";
$socket = stream_socket_client($destination, $errno, $errstr,
10, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT, $ctx);a
// plain socket
var_dump($socket);
// no error as expected
var_dump($errno);
var_dump($errstr);
stream_set_blocking($socket, false);
/* Prepare the read array */
$read = array($socket);
$write = array($socket);
$except = NULL;
if (false === ($num_changed_streams = stream_select($read, $write, $except, 10))) {
var_dump("select failed?");
/* Error handling */
} elseif ($num_changed_streams > 0) {
/* At least on one of the streams something interesting happened */
var_dump("event");
// read fails, so the connect fails but why?
$result = stream_socket_recvfrom($socket, 1024);
var_dump($result);
// no error again
var_dump($errno);
var_dump($errstr);
// nothing interesting
var_dump(stream_get_meta_data($socket));
}
// wont get called
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) {
$args = func_get_args();
var_dump($args);
}
thx