public function do_write($bForceWrite = false) { // If we haven't explicitly been told to try to write, don't. if (!$bForceWrite && $this->bBlocked) { true; } // Forced to write by the SE: unset blocked flag $this->bBlocked = false; $length = strlen($this->write_buffer); try { $written = parent::write($this->write_buffer, $length); if ($written < $length) { $this->write_buffer = substr($this->write_buffer, $written); $this->bBlocked = true; } else { $this->write_buffer = ''; } $this->on_write(); return true; } catch (socketException $e) { if (socket_strerror(socket_last_error()) == "Resource temporarily unavailable") { // Must check string, integer codes are nonportable. return false; } AirD::Log(AirD::LOGTYPE_INTERNAL, "Exception caught while writing to socket " . (int) $this->socket . ": " . $e->getMessage()); $old_socket = (int) $this->socket; $this->close(); $this->socket = $old_socket; $this->disconnected = true; $this->on_disconnect(); return false; } return false; }