Detect timeout of stream_socket_client using STREAM_CLIENT_ASYNC_CONNECT ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(apologies if this sends twice - email verification issues)

Is it possible to detect the timeout of a stream created with stream_socket_client() using the flag 'STREAM_CLIENT_ASYNC_CONNECT' ?

As soon as this flag is used, it seems there is no way to detect a timeout situation.

tcp://192.168.100.100:123 is a fictional, non-existent endpoint.


Code:
=======================

<?php
ini_set('default_socket_timeout', 1);

$flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT;
$conn = stream_socket_client('tcp://192.168.100.100:123', $errNo, $errStr, 1, $flags);
stream_set_timeout($conn, 1);

$read = array($conn);
$write = array($conn);
$e = null;
stream_select($read, $write, $e, 5, 0);

var_dump($read);
var_dump($write);
var_dump($errNo);
var_dump($errStr);
var_dump(stream_get_meta_data($conn));



Output:
=======================

array(0) {
}
array(0) {
}
int(0)
string(0) ""
array(7) {
  ["stream_type"]=>
  string(14) "tcp_socket/ssl"
  ["mode"]=>
  string(2) "r+"
  ["unread_bytes"]=>
  int(0)
  ["seekable"]=>
  bool(false)
  ["timed_out"]=>
  bool(false)
  ["blocked"]=>
  bool(true)
  ["eof"]=>
  bool(false)
}

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux