コード例 #1
0
ファイル: DnsUdpClient.cs プロジェクト: boethin/dnstools
        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
0
ファイル: DnsTcpClient.cs プロジェクト: boethin/dnstools
        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;
        }