本文整理汇总了PHP中resource::write方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::write方法的具体用法?PHP resource::write怎么用?PHP resource::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed The number of bytes that were actually written,
* or a PEAR_Error object on failure.
*
* @since 1.1.0
*/
protected function send($data)
{
$this->debug("Send: {$data}");
$result = $this->socket->write($data);
if (!$result || PEAR::isError($result)) {
$msg = $result ? $result->getMessage() : "unknown error";
return PEAR::raiseError("Failed to write to socket: {$msg}");
}
return $result;
}
示例2:
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed True on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.1.0
*/
function _send($data)
{
if ($this->_debug) {
echo "DEBUG: Send: {$data}\n";
}
if (PEAR::isError($error = $this->_socket->write($data))) {
return new PEAR_Error('Failed to write to socket: ' . $error->getMessage());
}
return true;
}
示例3: date
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed True on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.0
*/
function _send($data)
{
if ($this->_socket->eof()) {
return new PEAR_Error('Failed to write to socket: (connection lost!) ');
}
if (PEAR::isError($error = $this->_socket->write($data))) {
return new PEAR_Error('Failed to write to socket: ' . $error->getMessage());
}
if ($this->_debug) {
// C: means this data was sent by the client (this class)
echo "C: " . date("H:i:s") . " " . htmlspecialchars($data) . "\n";
$this->dbgDialog .= "C: {$data}";
}
return true;
}
示例4:
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed True on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.0
*/
function _send($data)
{
if ($this->_socket->eof()) {
return new PEAR_Error('Failed to write to socket: (connection lost!)');
}
if (PEAR::isError($error = $this->_socket->write($data))) {
return new PEAR_Error('Failed to write to socket: ' . $error->getMessage());
}
if ($this->_debug) {
// C: means this data was sent by the client (this class)
echo 'C: ' . $data;
$this->dbgDialog .= 'C: ' . $data;
}
return true;
}
示例5: sessionCommit
/**
* Commmit session data
* @param callable $cb Callback
* @return void
*/
public function sessionCommit($cb = null)
{
if (!$this->sessionFp || $this->sessionFlushing) {
if ($cb) {
call_user_func($cb, false);
}
return;
}
$this->sessionFlushing = true;
$data = $this->sessionEncode();
$l = strlen($data);
$cb = CallbackWrapper::wrap($cb);
$this->sessionFp->write($data, function ($file, $result) use($l, $cb) {
$file->truncate($l, function ($file, $result) use($cb) {
$this->sessionFlushing = false;
if ($cb) {
call_user_func($cb, true);
}
});
});
}
示例6: identifySender
/**
* Attempt to send the EHLO command and obtain a list of ESMTP
* extensions available, and failing that just send HELO.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
* @access private
*/
function identifySender()
{
if (PEAR::isError($this->socket->write("EHLO {$this->localhost}\r\n"))) {
return new PEAR_Error('write to socket failed');
}
$extensions = array();
if (!$this->validateAndParseResponse('250', $extensions)) {
if (PEAR::isError($this->socket->write("HELO {$this->localhost}\r\n"))) {
return new PEAR_Error('write to socket failed');
}
if (!$this->validateResponse('250')) {
return new PEAR_Error('HELO not accepted', $this->code);
}
return true;
}
for ($i = 0; $i < count($extensions); $i++) {
$verb = strtok($extensions[$i], ' ');
$arguments = substr($extensions[$i], strlen($verb) + 1, strlen($extensions[$i]) - strlen($verb) - 2);
$this->esmtp[$verb] = $arguments;
}
return true;
}
示例7:
/**
* Sends a command to the server
*
* @param string $cmd The command to send.
*
* @return void
*/
function _sendCmd($cmd)
{
$status = $this->_sock->getStatus();
if (is_a($status, 'PEAR_Error') || $status['eof']) {
return $this->_pear->raiseError('Failed to write to socket: connection lost');
}
$error = $this->_sock->write($cmd . "\r\n");
if (is_a($error, 'PEAR_Error')) {
return $this->_pear->raiseError('Failed to write to socket: ' . $error->getMessage());
}
$this->_debug("C: {$cmd}");
}
示例8:
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed The number of bytes that were actually written,
* or a PEAR_Error object on failure.
*
* @access private
* @since 1.1.0
*/
function _send($data)
{
$this->_debug("Send: {$data}");
$result = $this->_socket->write($data);
if (!$result || PEAR::isError($result)) {
$msg = $result ? $result->getMessage() : "unknown error";
return PEAR::raiseError("Failed to write to socket: {$msg}", null, PEAR_ERROR_RETURN);
}
return $result;
}
示例9: _send
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return integer The number of bytes that were actually written.
* @throws PEAR_Exception
*/
protected function _send($data)
{
$this->_debug("Send: {$data}");
$result = $this->_socket->write($data);
if ($result === false) {
return Net_SMTP::raiseError('Failed to write to socket: ' . $result->getMessage(), $result);
}
return $result;
}
示例10:
/**
* Sends a command to the server
*
* @param string $cmd The command to send.
*
* @return void
*/
function _sendCmd($cmd)
{
$status = $this->_sock->getStatus();
if (PEAR::isError($status) || $status['eof']) {
return PEAR::raiseError('Failed to write to socket: connection lost');
}
if (PEAR::isError($error = $this->_sock->write($cmd . "\r\n"))) {
return PEAR::raiseError('Failed to write to socket: ' . $error->getMessage());
}
$this->_debug("C: {$cmd}");
}
示例11: PEAR
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed The number of bytes that were actually written,
* or a PEAR_Error object on failure.
*
* @access private
* @since 1.1.0
*/
function _send($data)
{
$this->_debug("Send: {$data}");
$result = $this->_socket->write($data);
if (!$result || PEAR::isError($result)) {
$msg = $result ? $result->getMessage() : "unknown error";
$p = new PEAR();
return $p->raiseError("Failed to write to socket: {$msg}", null, PEAR_ERROR_RETURN);
}
// we have to set timeout, so it works..
//$this->setTimeout($this->_timeout);
return $result;
}
示例12:
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed True on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.1.0
*/
function _send($data)
{
$this->_debug("Send: {$data}");
if (PEAR::isError($error = $this->_socket->write($data))) {
return PEAR::raiseError('Failed to write to socket: ' . $error->getMessage());
}
return true;
}
示例13:
/**
* Private method for sending data to SMTP connection
*
* @param string $data data to be sent to SMTP server
* @param mixed $checkCode code to check for in server response, false to skip
* @return bool Success
* @access private
*/
function __smtpSend($data, $checkCode = '250')
{
if (!is_null($data)) {
$this->__smtpConnection->write($data . "\r\n");
}
if ($checkCode !== false) {
$response = $this->__smtpConnection->read();
if (!preg_match('/^' . $checkCode . '/', $response)) {
$this->smtpError = $response;
return false;
}
}
return true;
}
示例14:
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed True on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.1.0
*/
function _send($data)
{
$this->_debug("Send: {$data}");
$error = $this->_socket->write($data);
if ($error === false || PEAR::isError($error)) {
$msg = $error ? $error->getMessage() : "unknown error";
return PEAR::raiseError("Failed to write to socket: {$msg}");
}
return true;
}
示例15: _send
/**
* Send the given string of data to the server.
*
* @param string $data The string of data to send.
*
* @return mixed True on success or a PEAR_Error object on failure.
*
* @access private
* @since 1.1.0
*/
private function _send($data)
{
if ($this->_debug) {
echo "DEBUG: Send: {$data}\n";
}
if (Error::is_error($error = $this->_socket->write($data))) {
throw Error::raise('Failed to write to socket: ' . $error->getMessage());
}
return true;
}