Definition at line 31 of file TextRequest.cs.
Ntp.Analyzer.Monitor.Client.TextRequest.TextRequest |
( |
IPAddress |
ip, |
|
|
int |
port |
|
) |
| |
|
inline |
Ntp.Analyzer.Monitor.Client.TextRequest.TextRequest |
( |
IPEndPoint |
server | ) |
|
|
inline |
string Ntp.Analyzer.Monitor.Client.TextRequest.Send |
( |
string |
command | ) |
|
|
inline |
Implements Ntp.Common.Process.IRequest.
Definition at line 45 of file TextRequest.cs.
47 var clientSocket =
new Socket(
48 AddressFamily.InterNetwork,
54 IAsyncResult conRes = clientSocket.BeginConnect(
Server, null, null);
55 bool success = conRes.AsyncWaitHandle.WaitOne(3000,
true);
59 throw new ApplicationException(
"Failed to connect to server.");
62 byte[] sendBuffer = Encoding.UTF8.GetBytes(command);
65 clientSocket.Send(sendBuffer, 0, sendBuffer.Length, SocketFlags.None, out error);
67 const int size = 4096;
69 result =
new StringBuilder(4096);
70 var buffer =
new byte[size];
76 length = clientSocket.Receive(buffer, 0, size, SocketFlags.None, out error);
77 string response = Encoding.ASCII.GetString(buffer);
78 response = response.Substring(0, length);
86 Debug.WriteLine(ex.Message);
87 return "Failed to connect to server.";
91 if (clientSocket.IsBound)
92 clientSocket.Shutdown(SocketShutdown.Both);
StringBuilder Ntp.Analyzer.Monitor.Client.TextRequest.result |
|
private |
The documentation for this class was generated from the following file: