Example #1
0
 /**
  * check socket to see if a write/send/sendTo will not block
  *
  * @param float|NULL $sec maximum time to wait (in seconds), 0 = immediate polling, null = no limit
  * @return boolean true = socket ready (write will not block), false = timeout expired, socket is not ready
  * @throws Exception on error
  * @uses socket_select()
  */
 public function selectWrite($sec = 0)
 {
     $usec = $sec === null ? null : ($sec - floor($sec)) * 1000000;
     $w = array($this->resource);
     $ret = @socket_select($x, $w, $x, $sec, $usec);
     if ($ret === false) {
         throw Exception::createFromGlobalSocketOperation('Failed to select socket for writing');
     }
     return !!$ret;
 }