本文整理汇总了PHP中resource::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::disconnect方法的具体用法?PHP resource::disconnect怎么用?PHP resource::disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
/**
* Closes this connection
*
* @param boolean|string $connection - If connection is not given, or
* FALSE then connection that would be selected for writes would be
* closed. In a single-node configuration, that is then the whole
* connection, but if you are connected to a replica set, close() will
* only close the connection to the primary server.
*
* @return bool - Returns if the connection was successfully closed.
*/
public function close($connection = null)
{
if ($this->socket) {
$this->socket->disconnect();
$this->protocol = null;
}
//TODO: implement $connection handling
}
示例2: disconnect
/**
* This function close the FTP-connection
*
* @access public
* @return mixed Returns true on success, Jaws_Error on failure
*/
function disconnect()
{
$res = $this->_ftp->disconnect();
if (PEAR::isError($res)) {
return new Jaws_Error('Error while disconnecting from server ' . $this->_host, __FUNCTION__);
}
return true;
}
示例3:
/**
* Destructs the storage object.
*/
function __destruct()
{
$this->foowd->track('smdoc_db->destructor');
// clean up object cache
$this->objects->__destruct();
// close connection
$this->conn->disconnect();
$this->foowd->track();
}
示例4: disconnect
/**
* Attempt to disconnect from the SMTP server.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
* @access public
* @since 1.0
*/
function disconnect()
{
if (PEAR::isError($error = $this->_put('QUIT'))) {
return $error;
}
if (PEAR::isError($error = $this->_parseResponse(221))) {
return $error;
}
if (PEAR::isError($error = $this->_socket->disconnect())) {
return new PEAR_Error('Failed to disconnect socket: ' . $error->getMessage());
}
return true;
}
示例5: disconnect
/**
* Attempt to disconnect from the SMTP server.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
* @access public
*/
function disconnect()
{
if (PEAR::isError($this->socket->write("QUIT\r\n"))) {
return new PEAR_Error('write to socket failed');
}
if (!$this->validateResponse('221')) {
return new PEAR_Error('221 Bye not received');
}
if (PEAR::isError($this->socket->disconnect())) {
return new PEAR_Error('socket disconnect failed');
}
return true;
}
示例6: cmdLogout
/**
* Attempt to disconnect from the iMAP server.
*
* @return array Returns an array containing the response
*
* @access public
* @since 1.0
*/
function cmdLogout()
{
if (!$this->_connected) {
return new PEAR_Error('not connected!');
}
if (PEAR::isError($args = $this->_genericCommand('LOGOUT'))) {
return $args;
}
if (PEAR::isError($this->_socket->disconnect())) {
return new PEAR_Error('socket disconnect failed');
}
return $args;
// not for now
//return $this->_genericImapResponseParser($args,$cmdid);
}
示例7: cmdLogout
/**
* Attempt to disconnect from the iMAP server.
*
* @return array Returns an array containing the response
*
* @access public
* @since 1.0
*/
function cmdLogout()
{
if (!$this->_connected) {
return new PEAR_Error('not connected!');
}
$cmdid = $this->_getCmdId();
if (PEAR::isError($error = $this->_putCMD($cmdid, 'LOGOUT'))) {
return $error;
}
if (PEAR::isError($args = $this->_getRawResponse())) {
return $args;
}
if (PEAR::isError($this->_socket->disconnect())) {
return new PEAR_Error('socket disconnect failed');
}
return $args;
// not for now
//return $this->_genericImapResponseParser($args,$cmdid);
}
示例8: __smtp
/**
* Sends out email via SMTP
*
* @return bool Success
* @access private
*/
private function __smtp()
{
App::import('Core', array('CakeSocket'));
$this->__smtpConnection = new CakeSocket(array_merge(array('protocol' => 'smtp'), $this->smtpOptions));
if (!$this->__smtpConnection->connect()) {
$this->smtpError = $this->__smtpConnection->lastError();
return false;
} elseif (!$this->__smtpSend(null, '220')) {
return false;
}
$httpHost = env('HTTP_HOST');
if (isset($this->smtpOptions['client'])) {
$host = $this->smtpOptions['client'];
} elseif (!empty($httpHost)) {
$host = $httpHost;
} else {
$host = 'localhost';
}
if (!$this->__smtpSend("HELO {$host}", '250')) {
return false;
}
if (isset($this->smtpOptions['username']) && isset($this->smtpOptions['password'])) {
$authRequired = $this->__smtpSend('AUTH LOGIN', '334|503');
if ($authRequired == '334') {
if (!$this->__smtpSend(base64_encode($this->smtpOptions['username']), '334')) {
return false;
}
if (!$this->__smtpSend(base64_encode($this->smtpOptions['password']), '235')) {
return false;
}
} elseif ($authRequired != '503') {
return false;
}
}
if (!$this->__smtpSend('MAIL FROM: ' . $this->__formatAddress($this->from, true))) {
return false;
}
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($this->to, true))) {
return false;
}
foreach ($this->cc as $cc) {
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($cc, true))) {
return false;
}
}
foreach ($this->bcc as $bcc) {
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($bcc, true))) {
return false;
}
}
if (!$this->__smtpSend('DATA', '354')) {
return false;
}
$header = implode("\r\n", $this->__header);
$message = implode("\r\n", $this->__message);
if (!$this->__smtpSend($header . "\r\n\r\n" . $message . "\r\n\r\n\r\n.")) {
return false;
}
$this->__smtpSend('QUIT', false);
$this->__smtpConnection->disconnect();
return true;
}
示例9: disconnect
/**
* Attempt to disconnect from the SMTP server.
*
* @throws PEAR_Exception
*/
public function disconnect()
{
//if (PEAR::isError($error = $this->_put('QUIT'))) {
if (($error = $this->_put('QUIT')) === false) {
return $error;
}
//if (PEAR::isError($error = $this->_parseResponse(221))) {
if (($error = $this->_parseResponse(221)) === false) {
return $error;
}
//if (PEAR::isError($error = $this->_socket->disconnect())) {
if (($error = $this->_socket->disconnect()) === false) {
return Net_SMTP::raiseError('Failed to disconnect socket: ' . $error->getMessage());
}
return true;
}
示例10:
/**
* Logs out of the server and terminates the connection.
*
* @param boolean $sendLogoutCMD Whether to send LOGOUT command before
* disconnecting.
*
* @return boolean True on success, PEAR_Error otherwise.
*/
function _cmdLogout($sendLogoutCMD = true)
{
if (NET_SIEVE_STATE_DISCONNECTED == $this->_state) {
return PEAR::raiseError('Not currently connected', 1);
}
if ($sendLogoutCMD) {
if (PEAR::isError($res = $this->_doCmd('LOGOUT'))) {
return $res;
}
}
$this->_sock->disconnect();
$this->_state = NET_SIEVE_STATE_DISCONNECTED;
return true;
}
示例11: cmdQuit
/**
* Close connection to the server
*
* @access public
*/
function cmdQuit()
{
// Tell the server to close the connection
$response = $this->_sendCommand('QUIT');
if (PEAR::isError($response)) {
return $response;
}
switch ($response) {
case 205:
// RFC977: 'closing connection - goodbye!'
// If socket is still open, close it.
if ($this->isConnected()) {
$this->_socket->disconnect();
}
return true;
break;
default:
return PEAR::throwError('Unidentified response code', $response, $this->currentStatusResponse());
}
}
示例12: close
/**
* Close the file and forget the filehandle
*/
function close()
{
$this->dbh->disconnect();
$this->dbh = false;
}
示例13: disconnect
protected function disconnect()
{
$this->objConnection->disconnect();
unset($this->objConnection);
}
示例14: disconnect
/**
* Attempt to disconnect from the SMTP server.
*
* @throws PEAR_Exception
*/
public function disconnect()
{
try {
$this->_put('QUIT');
$this->_parseResponse(221);
$this->_socket->disconnect();
} catch (Net_Socket2_Exception $e) {
// Already disconnected? Silence!
}
return true;
}
示例15: disconnect
/**
* Desconnects from SMSC/SMS gateway gracefully
* @access public
* @return boolean Always TRUE
*/
public function disconnect()
{
if ($this->state == ESS_BIND_TX || $this->state == ESS_BIND_RX) {
l('ESME sending UNBIND command...');
$this->sock->send($this->form_pdu(UNBIND));
$pdu = $this->sock->pdu_wait_for(UNBIND | ACK, $this->sqn);
$res = $this->parse_pdu_header(substr($pdu, 0, 16));
if ($res['stat'] !== 0) {
l('UNBIND failed: ' . $res['stat'] . '.', L_WARN);
} else {
l('UNBIND done.');
}
}
$this->state = ESS_DISCONNECTED;
$this->sock->disconnect();
return true;
}