/// <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();
}
版权归属:
管理员
许可协议:
本文使用《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》协议授权
评论区