Show / Hide Table of Contents

Class NtpRequest

Make NTP request.

  1. Create the object by Create(IPEndPoint, Action<NtpPacket>) method.

  2. Use Send() method to send requests. 3. Call Close() to release the socket AFTER you have received the response or some timeout. If you close the socket too early, you may miss the response.

  3. Call Close() to release the socket AFTER you have received the response or some timeout. If you close the socket too early, you may miss the response.

Inheritance
System.Object
NtpRequest
Namespace: LiteNetLib.Utils
Assembly: LiteNetLib.dll
Syntax
public sealed class NtpRequest : INetSocketListener

Fields

DefaultPort

Declaration
public const int DefaultPort = 123
Field Value
Type Description
System.Int32

Methods

Close()

Close socket.

Declaration
public void Close()

Create(IPAddress, Action<NtpPacket>)

Create the requests for NTP server (default port), open socket.

Declaration
public static NtpRequest Create(IPAddress ipAddress, Action<NtpPacket> onRequestComplete)
Parameters
Type Name Description
System.Net.IPAddress ipAddress

NTP Server address.

System.Action<NtpPacket> onRequestComplete

callback (called from other thread!)

Returns
Type Description
NtpRequest

Create(IPEndPoint, Action<NtpPacket>)

Create the requests for NTP server, open socket.

Declaration
public static NtpRequest Create(IPEndPoint endPoint, Action<NtpPacket> onRequestComplete)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint

NTP Server address.

System.Action<NtpPacket> onRequestComplete

callback (called from other thread!)

Returns
Type Description
NtpRequest

Create(String, Action<NtpPacket>)

Create the requests for NTP server (default port), open socket.

Declaration
public static NtpRequest Create(string ntpServerAddress, Action<NtpPacket> onRequestComplete)
Parameters
Type Name Description
System.String ntpServerAddress

NTP Server address.

System.Action<NtpPacket> onRequestComplete

callback (called from other thread!)

Returns
Type Description
NtpRequest

Create(String, Int32, Action<NtpPacket>)

Create the requests for NTP server, open socket.

Declaration
public static NtpRequest Create(string ntpServerAddress, int port, Action<NtpPacket> onRequestComplete)
Parameters
Type Name Description
System.String ntpServerAddress

NTP Server address.

System.Int32 port

port

System.Action<NtpPacket> onRequestComplete

callback (called from other thread!)

Returns
Type Description
NtpRequest

Send()

Send request to the NTP server calls callback (if success). In case of error the callbacke is called with null param.

Declaration
public void Send()
Back to top Generated by DocFX