本文整理汇总了PHP中Daemon::exportBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::exportBytes方法的具体用法?PHP Daemon::exportBytes怎么用?PHP Daemon::exportBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::exportBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stdin
public function stdin($buf)
{
// from mysqld to client.
if (Daemon::$settings['mod' . $this->appInstance->modname . 'protologging']) {
Daemon::log('MysqlProxy: Server --> Client: ' . Daemon::exportBytes($buf) . "\n\n");
}
$this->downstream->write($buf);
}
示例2: read
public function read($connId, $n)
{
if (!isset($this->buf[$connId])) {
return FALSE;
}
if (isset($this->readEvents[$connId])) {
if (Daemon::$useSockets) {
$read = socket_read(Daemon::$worker->pool[$connId], $n);
if ($read === FALSE) {
$no = socket_last_error(Daemon::$worker->pool[$connId]);
if ($no !== 11) {
Daemon::log(get_class($this) . '::' . __METHOD__ . ': connId = ' . $connId . '. Socket error. (' . $no . '): ' . socket_strerror($no));
$this->onFailureEvent($connId, array());
}
}
} else {
$read = fread(Daemon::$worker->pool[$connId], $n);
}
} else {
$read = event_buffer_read($this->buf[$connId], $n);
}
if ($read === '' || $read === NULL || $read === FALSE) {
if (Daemon::$settings['logreads']) {
Daemon::log('read(' . $connId . ',' . $n . ') interrupted.');
}
unset(Daemon::$worker->readPoolState[$connId]);
return FALSE;
}
if (Daemon::$settings['logreads']) {
Daemon::log('read(' . $connId . ',' . $n . ',[' . gettype($read) . '-' . ($read === FALSE ? 'false' : strlen($read)) . ':' . Daemon::exportBytes($read) . ']).');
}
return $read;
}
示例3: stdin
public function stdin($buf)
{
$this->buf .= $buf;
if (Daemon::$settings['mod' . $this->appInstance->modname . 'protologging']) {
Daemon::log('Server --> Client: ' . Daemon::exportBytes($buf) . "\n\n");
}
start:
$this->buflen = strlen($this->buf);
if (($packet = $this->getPacketHeader()) === FALSE) {
return;
}
$this->seq = $packet[1] + 1;
if ($this->cstate === 0) {
if ($this->buflen < 4 + $packet[0]) {
return;
}
// no whole packet yet
$this->cstate = 1;
$p = 4;
$this->protover = ord(binarySubstr($this->buf, $p++, 1));
$this->serverver = '';
while ($p < $this->buflen) {
$c = binarySubstr($this->buf, $p++, 1);
if ($c === "") {
break;
}
$this->serverver .= $c;
}
$this->threadId = $this->bytes2int(binarySubstr($this->buf, $p, 4));
$p += 4;
$this->scramble = binarySubstr($this->buf, $p, 8);
$p += 9;
$this->serverCaps = $this->bytes2int(binarySubstr($this->buf, $p, 2));
$p += 2;
$this->serverLang = ord(binarySubstr($this->buf, $p++, 1));
$this->serverStatus = $this->bytes2int(binarySubstr($this->buf, $p, 2));
$p += 2;
$p += 13;
$restScramble = binarySubstr($this->buf, $p, 12);
$this->scramble .= $restScramble;
$p += 13;
$this->auth();
} else {
if ($this->buflen < 4 + $packet[0]) {
return;
}
// not whole packet yet
$p = 4;
$fieldCount = ord(binarySubstr($this->buf, $p, 1));
$p += 1;
if ($fieldCount === 0xff) {
$u = unpack('v', binarySubstr($this->buf, $p, 2));
$p += 2;
$this->errno = $u[1];
$state = binarySubstr($this->buf, $p, 6);
$p = +6;
$this->errmsg = binarySubstr($this->buf, $p, $packet[0] + 4 - $p);
$this->onError();
} elseif ($fieldCount === 0x0) {
if ($this->cstate === 2) {
$this->cstate = 4;
}
$this->affectedRows = $this->parseEncodedBinary($this->buf, $p);
$this->insertId = $this->parseEncodedBinary($this->buf, $p);
$u = unpack('v', binarySubstr($this->buf, $p, 2));
$p += 2;
$this->serverStatus = $u[1];
$u = unpack('v', binarySubstr($this->buf, $p, 2));
$p += 2;
$this->warnCount = $u[1];
$this->message = binarySubstr($this->buf, $p, $packet[0] + 4 - $p);
$this->onResultDone();
} elseif ($fieldCount === 0xfe) {
++$this->instate;
if ($this->instate === 3) {
$this->onResultDone();
}
} else {
--$p;
if ($this->instate === 0) {
$extra = $this->parseEncodedBinary($this->buf, $p);
++$this->instate;
} elseif ($this->instate === 1) {
$field = array();
$field['catalog'] = $this->parseEncodedString($this->buf, $p);
$field['db'] = $this->parseEncodedString($this->buf, $p);
$field['table'] = $this->parseEncodedString($this->buf, $p);
$field['org_table'] = $this->parseEncodedString($this->buf, $p);
$field['name'] = $this->parseEncodedString($this->buf, $p);
$field['org_name'] = $this->parseEncodedString($this->buf, $p);
++$p;
// filler
$u = unpack('v', binarySubstr($this->buf, $p, 2));
$p += 2;
$field['charset'] = $u[1];
$u = unpack('V', binarySubstr($this->buf, $p, 4));
$p += 4;
$field['length'] = $u[1];
$field['type'] = ord(binarySubstr($this->buf, $p, 1));
++$p;
//.........这里部分代码省略.........
示例4: stdin
public function stdin($buf)
{
$this->buf .= $buf;
if (Daemon::$settings['mod' . $this->appInstance->modname . 'protologging']) {
Daemon::log('Server --> Client: ' . Daemon::exportBytes($buf) . "\n\n");
}
start:
$this->buflen = strlen($this->buf);
if ($this->buflen < 5) {
return;
}
// Not enough data buffered yet
$type = binarySubstr($this->buf, 0, 1);
list(, $length) = unpack('N', binarySubstr($this->buf, 1, 4));
$length -= 4;
if ($this->buflen < 5 + $length) {
return;
}
// Not enough data buffered yet
$packet = binarySubstr($this->buf, 5, $length);
$this->buf = binarySubstr($this->buf, 5 + $length);
if ($type === 'R') {
list(, $authType) = unpack('N', $packet);
if ($authType === 0) {
if (Daemon::$settings['mod' . $this->appInstance->modname . 'protologging']) {
Daemon::log(__CLASS__ . ': auth. ok.');
}
$this->cstate = 4;
// Auth. ok
foreach ($this->onConnected as $cb) {
call_user_func($cb, $this, TRUE);
}
} elseif ($authType === 2) {
Daemon::log(__CLASS__ . ': Unsupported authentication method: KerberosV5.');
$this->cstate = 3;
// Auth. error
$this->finish();
// Unsupported, finish
} elseif ($authType === 3) {
$this->sendPacket('p', $this->password);
// Password Message
$this->cstate = 2;
// Auth. packet sent
} elseif ($authType === 4) {
$salt = binarySubstr($packet, 4, 2);
$this->sendPacket('p', crypt($this->password, $this->user));
// Password Message
$this->cstate = 2;
// Auth. packet sent
} elseif ($authType === 5) {
$salt = binarySubstr($packet, 4, 4);
$this->sendPacket('p', 'md5' . md5(md5($this->password, $this->user) . $salt));
// Password Message
$this->cstate = 2;
// Auth. packet sent
} elseif ($authType === 6) {
Daemon::log(__CLASS__ . ': Unsupported authentication method: SCM.');
$this->cstate = 3;
// Auth. error
$this->finish();
// Unsupported, finish
} elseif ($authType == 9) {
Daemon::log(__CLASS__ . ': Unsupported authentication method: GSS.');
$this->cstate = 3;
// Auth. error
$this->finish();
// Unsupported, finish
}
} elseif ($type === 'T') {
list(, $numfields) = unpack('n', binarySubstr($packet, 0, 2));
$p = 2;
for ($i = 0; $i < $numfields; ++$i) {
list($name) = $this->decodeNULstrings($packet, 1, $p);
$field = unpack('NtableOID/nattrNo/NdataType/ndataTypeSize/NtypeMod/nformat', binarySubstr($packet, $p, 18));
$p += 18;
$field['name'] = $name;
$this->resultFields[] = $field;
}
} elseif ($type === 'D') {
list(, $numfields) = unpack('n', binarySubstr($packet, 0, 2));
$p = 2;
$row = array();
for ($i = 0; $i < $numfields; ++$i) {
list(, $length) = unpack('N', binarySubstr($packet, $p, 4));
$p += 4;
if ($length === 4294967295.0) {
$length = -1;
}
// hack
if ($length === -1) {
$value = NULL;
} else {
$value = binarySubstr($packet, $p, $length);
$p += $length;
}
$row[$this->resultFields[$i]['name']] = $value;
}
$this->resultRows[] = $row;
} elseif ($type === 'G') {
// The backend is ready to copy data from the frontend to a table; see Section 45.2.5.
//.........这里部分代码省略.........