NTP Protocol handling class

category Zend
package Zend_TimeSync
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_TimeSync_Protocol

 Methods

NTP class constructor, sets the timeserver and port number

__construct(string $timeserver, integer $port = 123

Parameters

$timeserver

string

Adress of the timeserver to connect to

$port

integer

(Optional) Port for this timeserver

Query this timeserver without using the fallback mechanism

getDate(string|\Zend_Locale $locale = null) : \Zend_Date
Inherited

Parameters

$locale

string\Zend_Locale

(Optional) Locale

Returns

\Zend_Date

Return information sent/returned from the timeserver

getInfo() : array
Inherited

Returns

array

Connect to the specified timeserver.

_connect() : void
Inherited

Exceptions

\Zend_TimeSync_Exception When the connection failed

Disconnects from the peer, closes the socket.

_disconnect() : void
Inherited

Extracts the binary data returned from the timeserver

_extract(string|array $binary) : integer
inherited_from \Zend_TimeSync_Protocol::_extract()

Parameters

$binary

stringarray

Data returned from the timeserver

Returns

integerDifference in seconds

Abstract method that extracts the binary data returned from the timeserver

_extract(string|array $data) : integer
Inherited

Parameters

$data

stringarray

Data returned from the timeserver

Returns

integer

Calculates a 32bit signed fixed point number

_getFloat(string $input) : float

Parameters

$input

string

Returns

float

Calculates a 32bit integer

_getInteger(string $input) : integer

Parameters

$input

string

Returns

integer

Calculates a 64bit timestamp

_getTimestamp(string $input) : float

Parameters

$input

string

Returns

float

Prepare local timestamp for transmission in our request packet

_prepare() : string

NTP timestamps are represented as a 64-bit fixed-point number, in seconds relative to 0000 UT on 1 January 1900. The integer part is in the first 32 bits and the fraction part in the last 32 bits

inherited_from \Zend_TimeSync_Protocol::_prepare()

Returns

string

Abstract method that prepares the data to send to the timeserver

_prepare() : mixed
Inherited

Returns

mixed

Reads the data returned from the timeserver

_read() : array

This will return an array with binary data listing:

inherited_from \Zend_TimeSync_Protocol::_read()

Exceptions

\Zend_TimeSync_Exception When timeserver can not be connected

Returns

array

Abstract method that reads the data returned from the timeserver

_read() : mixed
Inherited

Returns

mixed

Sends the NTP packet to the server

_write(string $data) : void
inherited_from \Zend_TimeSync_Protocol::_write()

Parameters

$data

string

Data to send to the timeserver

Abstract method that writes data to to the timeserver

_write(string $data) : void
Inherited

Parameters

$data

string

Data to write

 Properties

 

Exceptions that might have occured

$_exceptions : array

Default

 

Holds information passed/returned from timeserver

$_info : array

Default

array()
 

NTP port number (123) assigned by the Internet Assigned Numbers Authority

$_port : integer

Default

123
 

Holds the current socket connection

$_socket : array

Default

 

Hostname for timeserver

$_timeserver : string

Default