/// <summary> /// 获取指定网卡IP /// </summary> /// <param name="servicePoint"></param> /// <param name="remoteEndPoint"></param> /// <param name="retryCount"></param> /// <returns></returns> public IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount) { if (!string.IsNullOrWhiteSpace(_configuration.IP)) { IPAddress address = IPAddress.Parse(_configuration.IP); return new IPEndPoint(address, 0); } return new IPEndPoint(IPAddress.Any, 0); } public static void Main() { HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://MyServer"); request.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(BindIPEndPointCallback); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); }
C# HttpWebRequest 多网卡指定IP下载
本文作者:admin
发表评论