本文整理汇总了C#中Request.SetTimestamp方法的典型用法代码示例。如果您正苦于以下问题:C# Request.SetTimestamp方法的具体用法?C# Request.SetTimestamp怎么用?C# Request.SetTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.SetTimestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvalidOperationException
IAsyncResult IDnsClient.BeginProcess(Request request, AsyncCallback callback, object state)
{
Internal.AsyncResult<Response> result = new Internal.AsyncResult<Response>(callback, state);
// send request
Datagram qdata = request.Data;
if (qdata.Length > DatagramMaxLength) // can actually never happen
throw new InvalidOperationException(String.Format(
"Request message length exceeds {0} bytes.", DatagramMaxLength));
// LogMessage
LogRequest(qdata.Length);
request.SetTimestamp();
base.BeginSend(qdata, qdata.Length, RemoteEP, new AsyncCallback(AsyncRequestSent), result);
return result;
}
示例2: ArgumentNullException
IAsyncResult IDnsClient.BeginProcess(Request request, AsyncCallback callback, object state)
{
if (object.ReferenceEquals(null, request))
throw new ArgumentNullException("request");
Internal.AsyncResult<Response> result = new Internal.AsyncResult<Response>(callback, state);
// create request datagram, prefixed with the two byte length field
Datagram qdata = Datagram.GetPrefixed(request.Data);
NetworkStream ns = base.GetStream();
if (RequestSending != null)
RequestSending(this, new MessageEventArgs(request, ns, (IPEndPoint)Client.RemoteEndPoint));
// LogMessage
LogRequest(qdata.Length);
// asynchronously send prefixed request message
request.SetTimestamp();
ns.BeginWrite(qdata, 0, qdata.Length, new AsyncCallback(AsyncRequestWritten), result);
return result;
}
示例3: ArgumentNullException
Response IDnsClient.Process(Request request)
{
if (object.ReferenceEquals(null, request))
throw new ArgumentNullException("request");
if (!((IDnsClient)this).Connected)
throw new InvalidOperationException(
"The operation requires an IP address assigned with the client (use the Connect method).");
// send request
Datagram qdata = request.Data;
if (qdata.Length > DatagramMaxLength) // can actually never happen
throw new InvalidOperationException(String.Format(
"Request message length exceeds {0} bytes.", DatagramMaxLength));
// LogMessage
LogRequest(qdata.Length);
request.SetTimestamp();
base.Send(qdata, qdata.Length, RemoteEP);
// receive response
// Blocks until a message returns on this socket from a remote host.
IPEndPoint remote = new IPEndPoint(IPAddress.Any, 0);
Datagram rdata = (Datagram)base.Receive(ref remote);
Response response = Response.Create(rdata, DateTime.Now);
// LogMessage
LogResponse(response, remote);
return response;
}