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

Public Member Functions

 __construct ($timeserver, $port)
 
- Public Member Functions inherited from Zend_TimeSync_Protocol
 getInfo ()
 
 getDate ($locale=null)
 

Protected Member Functions

 _prepare ()
 
 _read ()
 
 _write ($data)
 
 _extract ($result)
 
- Protected Member Functions inherited from Zend_TimeSync_Protocol
 _prepare ()
 
 _read ()
 
 _write ($data)
 
 _extract ($data)
 
 _connect ()
 
 _disconnect ()
 

Protected Attributes

 $_port = 37
 
- Protected Attributes inherited from Zend_TimeSync_Protocol
 $_socket
 
 $_exceptions
 
 $_timeserver
 
 $_info = array()
 

Detailed Description

Definition at line 35 of file Sntp.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $timeserver,
  $port 
)

Class constructor, sets the timeserver and port number

Parameters
string$timeserverTimeserver to connect to
integer$portPort of the timeserver when it differs from the default port

Definition at line 57 of file Sntp.php.

58  {
59  $this->_timeserver = 'udp://' . $timeserver;
60  if ($port !== null) {
61  $this->_port = $port;
62  }
63  }

Member Function Documentation

◆ _extract()

_extract (   $result)
protected

Extracts the data returned from the timeserver

Parameters
string$resultData to extract
Returns
integer

Definition at line 107 of file Sntp.php.

108  {
109  $dec = hexdec('7fffffff');
110  $time = abs(($dec - hexdec(bin2hex($result))) - $dec);
111  $time -= 2208988800;
112  // Socket delay
113  $time -= $this->_delay;
114 
115  $this->_info['offset'] = $this->_delay;
116 
117  return $time;
118  }

◆ _prepare()

_prepare ( )
protected

Prepares the data that will be send to the timeserver

Returns
array

Definition at line 70 of file Sntp.php.

71  {
72  return "\n";
73  }

◆ _read()

_read ( )
protected

Reads the data returned from the timeserver

Returns
string

Definition at line 80 of file Sntp.php.

81  {
82  $result = fread($this->_socket, 49);
83  $this->_delay = (($this->_delay - time()) / 2);
84 
85  return $result;
86  }

◆ _write()

_write (   $data)
protected

Writes data to to the timeserver

Parameters
string$dataData to write to the timeserver
Returns
void

Definition at line 94 of file Sntp.php.

95  {
96  $this->_connect();
97  $this->_delay = time();
98  fputs($this->_socket, $data);
99  }

Field Documentation

◆ $_port

$_port = 37
protected

Definition at line 42 of file Sntp.php.


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