net实现ping的实例代码
来源:诚信在线    发布时间:2017-07-01 15:08:33

  ///

  writer.WriteEndElement();

  class ServicePinger

  throw new ArgumentException("siteUrl can't be null");

  throw new ArgumentException("siteName can't be null");

  if (serviceUrl == null)

  {

  }

  {

  writer.WriteElementString("value", pingingSiteUrl);

  writer.WriteElementString("value", pingingSiteName);

  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUrlToPing);

  if (siteName == null)

  request.Timeout = timeoutInMilliseconds;

  throw new ArgumentException("siteUrl can't be empty");

  {

  serviceUrlToPing = serviceUrl;

  pingingSiteName = siteName;

  {

  }

  }

  public ServicePinger(string siteName, string siteUrl, string serviceUrl)

  复制代码 代码以下:

  ///

  {

  pingingSiteUrl = siteUrl;

  public void Ping()

  if (serviceUrl.Length == 0)

  throw new ArgumentException("serviceUrl can't be empty");

  private string serviceUrlToPing = string.Empty;

  private int timeoutInMilliseconds = 3000;

  }

  writer.WriteElementString("methodName", "weblogUpdates.ping");

  Stream stream = (Stream)request.GetRequestStream();

  request.Credentials = CredentialCache.DefaultNetworkCredentials;

  writer.WriteStartElement("param");

  log.Error(ex);

  /// Does the actual pinging of the service

  writer.WriteEndElement();

  log.Error(ex);

  if (siteName.Length == 0)

  writer.WriteStartElement("methodCall");

  private string pingingSiteName = string.Empty;

  }

  {

  private static readonly ILog log = LogManager.GetLogger(typeof(ServicePinger));

  private string pingingSiteUrl = string.Empty;

  writer.WriteStartElement("param");

  if (siteUrl.Length == 0)

  writer.WriteEndElement();

  writer.WriteStartDocument();

  {

  request.ContentType = "text/xml";

  }

  request.GetResponse();

  try

  catch (InvalidOperationException ex)

  writer.WriteEndElement();

  using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.ASCII))

  }

  writer.WriteStartElement("params");

  catch (NotSupportedException ex)

  request.Method = "POST";

  throw new ArgumentException("siteName can't be empty");

  if (siteUrl == null)

  throw new ArgumentException("serviceUrl can't be null");


诚信在线 除注明原创以外,其余均来自互联网以及微信朋友圈,如有侵权请联系站长立即删除!
文章地址:http://www.my517517.com/MS/20170701380.html



上一篇:PHP实现下载远程图片保存到本地的方法 下一篇:C# Base64编码