1 # bool pq\Connection::flush()
3 Flush pending writes on the connection.
4 Call after sending any command or data on a nonblocking connection.
6 If it returns FALSE, wait for the socket to become read or write-ready.
7 If it becomes write-ready, call pq\Connection::flush() again.
8 If it becomes read-ready, call pq\Connection::poll(), then call pq\Connection::flush() again.
9 Repeat until pq\Connection::flush() returns TRUE.
12 > This method was added in v1.1.0, resp. v2.1.0.
20 * bool, whether everything has been flushed.
24 * pq\Exception\InvalidArgumentException
25 * pq\Exception\RuntimeException when no asynchronous operation is active, or flushing failed
30 $c = new pq\Connection();
31 $c->nonblocking = true;
33 $c->execAsync("SELECT '".str_repeat("a", 6e7)."'", function($r) {
38 $flushed = $c->flush();
40 while (!$flushed || $c->busy) {
41 $r = $c->busy ? [$c->socket] : null;
42 $w = !$flushed ?[$c->socket] : null;
44 if (stream_select($r, $w, $e, null)) {
46 printf("P%d", $c->poll());
49 printf("F%d", $flushed = $c->flush());
54 } while ($c->getResult());
59 F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0
61 F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F1P3P3P3P3P3P3P3P3
63 P3P3P3P3P3P3P3P3P3P3P3P3P3P3