protected function _send($args)
{
if (empty($this->connection)) {
if (!$this->connect($this->host, $this->port)) {
return false;
}
}
$command = '*' . count($args) . "\r\n";
foreach ($args as $arg) {
$command .= "\$" . strlen($arg) . "\r\n" . $arg . "\r\n";
}
$w = fwrite($this->connection, $command);
if (!$w) {
//if connection was lost
$this->connect($this->host, $this->port);
if (!fwrite($this->connection, $command)) {
$this->reportError('command was not sent');
return false;
}
}
$answer = $this->_read_reply();
if ($answer === false && $this->repeat_reconnected) {
if (fwrite($this->connection, $command)) {
$answer = $this->_read_reply();
}
$this->repeat_reconnected = false;
}
return $answer;
}