NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Monitor.Client.BinaryRequest Class Reference
Inheritance diagram for Ntp.Analyzer.Monitor.Client.BinaryRequest:
Collaboration diagram for Ntp.Analyzer.Monitor.Client.BinaryRequest:

Public Member Functions

 BinaryRequest (IPAddress ip, int port)
 
byte[] Send (string command)
 
- Public Member Functions inherited from Ntp.Analyzer.Monitor.Client.Request
override string ToString ()
 

Additional Inherited Members

- Protected Member Functions inherited from Ntp.Analyzer.Monitor.Client.Request
 Request (IPAddress ip, int port)
 
 Request (IPEndPoint server)
 
- Properties inherited from Ntp.Analyzer.Monitor.Client.Request
IPEndPoint Server [get]
 

Detailed Description

Definition at line 29 of file BinaryRequest.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Monitor.Client.BinaryRequest.BinaryRequest ( IPAddress  ip,
int  port 
)
inline

Definition at line 31 of file BinaryRequest.cs.

32  : base(ip, port)
33  {
34  }

Member Function Documentation

byte [] Ntp.Analyzer.Monitor.Client.BinaryRequest.Send ( string  command)
inline

Definition at line 36 of file BinaryRequest.cs.

37  {
38  var clientSocket = new Socket(
39  AddressFamily.InterNetwork,
40  SocketType.Stream,
41  ProtocolType.Tcp);
42 
43  clientSocket.Connect(Server);
44 
45  byte[] sendBuffer = Encoding.UTF8.GetBytes(command);
46 
47  SocketError error;
48  clientSocket.Send(sendBuffer, 0, sendBuffer.Length, SocketFlags.None, out error);
49 
50  const int size = 4096;
51 
52  var stream = new MemoryStream(size);
53  var buffer = new byte[size];
54 
55  int length;
56 
57  do
58  {
59  length = clientSocket.Receive(buffer, 0, size, SocketFlags.None, out error);
60  stream.Write(buffer, 0, length);
61  } while (length > 0);
62 
63  clientSocket.Shutdown(SocketShutdown.Both);
64  clientSocket.Close();
65 
66  return stream.ToArray();
67  }

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