public function write($data)
{
$history = new WriteHistory(self::WRITE_RETRIES);
for ($written = 0, $fwrite = 0; $written < strlen($data); $written += $fwrite) {
$fwrite = $this->_wrapper()->fwrite($this->_socket, substr($data, $written));
$history->log($fwrite);
if ($history->isFullWithNoWrites()) {
throw new Exception\SocketException(sprintf('fwrite() failed to write data after %u tries', self::WRITE_RETRIES));
}
}
}