1 # void pq\Connection::resetAsync()
3 [Asynchronously](pq/Connection/:%20Asynchronous%20Usage) reset a possibly broken connection to a working state.
11 * pq\Exception\InvalidArgumentException
12 * pq\Exception\BadMethodCallException
13 * pq\Exception\RuntimeException
22 // wait until the stream becomes writable
23 $w = array($c->socket);
26 if (stream_select($r, $w, $e, null)) {
28 // loop until the connection is established
33 case pq\Connection::POLLING_READING:
34 // we should wait for the stream to be read-ready
35 $r = array($c->socket);
36 stream_select($r, $w, $e, NULL);
39 case pq\Connection::POLLING_WRITING:
40 // we should wait for the stream to be write-ready
41 $w = array($c->socket);
43 stream_select($r, $w, $e, null);
46 case pq\Connection::POLLING_FAILED:
47 printf("Connection failed: %s\n", $c->errorMessage);
50 case pq\Connection::POLLING_OK:
51 printf("Connection completed\n");