Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Zend_TimeSync_Protocol Class Reference
Inheritance diagram for Zend_TimeSync_Protocol:
Zend_TimeSync_Ntp Zend_TimeSync_Sntp

Public Member Functions

 getInfo ()
 
 getDate ($locale=null)
 

Protected Member Functions

 _prepare ()
 
 _read ()
 
 _write ($data)
 
 _extract ($data)
 
 _connect ()
 
 _disconnect ()
 

Protected Attributes

 $_socket
 
 $_exceptions
 
 $_timeserver
 
 $_info = array()
 

Detailed Description

Definition at line 30 of file Protocol.php.

Member Function Documentation

◆ _connect()

_connect ( )
protected

Connect to the specified timeserver.

Returns
void
Exceptions
Zend_TimeSync_ExceptionWhen the connection failed

Definition at line 96 of file Protocol.php.

97  {
98  $socket = @fsockopen($this->_timeserver, $this->_port, $errno, $errstr,
99  Zend_TimeSync::$options['timeout']);
100  if ($socket === false) {
101  throw new Zend_TimeSync_Exception('could not connect to ' .
102  "'$this->_timeserver' on port '$this->_port', reason: '$errstr'");
103  }
104 
105  $this->_socket = $socket;
106  }
fsockopen(&$errorNumber, &$errorMessage)
Definition: http_mock.php:37
static $options
Definition: TimeSync.php:72

◆ _disconnect()

_disconnect ( )
protected

Disconnects from the peer, closes the socket.

Returns
void

Definition at line 113 of file Protocol.php.

114  {
115  @fclose($this->_socket);
116  $this->_socket = null;
117  }

◆ _extract()

_extract (   $data)
abstractprotected

Abstract method that extracts the binary data returned from the timeserver

Parameters
string | array$dataData returned from the timeserver
Returns
integer

◆ _prepare()

_prepare ( )
abstractprotected

Abstract method that prepares the data to send to the timeserver

Returns
mixed

◆ _read()

_read ( )
abstractprotected

Abstract method that reads the data returned from the timeserver

Returns
mixed

◆ _write()

_write (   $data)
abstractprotected

Abstract method that writes data to to the timeserver

Parameters
string$dataData to write
Returns
void

◆ getDate()

getDate (   $locale = null)

Query this timeserver without using the fallback mechanism

Parameters
string | Zend_Locale$locale(Optional) Locale
Returns
Zend_Date

Definition at line 140 of file Protocol.php.

141  {
142  $this->_write($this->_prepare());
143  $timestamp = $this->_extract($this->_read());
144 
145  $date = new Zend_Date($this, null, $locale);
146  return $date;
147  }

◆ getInfo()

getInfo ( )

Return information sent/returned from the timeserver

Returns
array

Definition at line 124 of file Protocol.php.

125  {
126  if (empty($this->_info) === true) {
127  $this->_write($this->_prepare());
128  $timestamp = $this->_extract($this->_read());
129  }
130 
131  return $this->_info;
132  }

Field Documentation

◆ $_exceptions

$_exceptions
protected

Definition at line 44 of file Protocol.php.

◆ $_info

$_info = array()
protected

Definition at line 58 of file Protocol.php.

◆ $_socket

$_socket
protected

Definition at line 37 of file Protocol.php.

◆ $_timeserver

$_timeserver
protected

Definition at line 51 of file Protocol.php.


The documentation for this class was generated from the following file: