Unable to connect to the remote server when selecting IpEndPoint
===

I've got c# code running on a computer with multiple IP addresses, and I've got following code to select an IP address for a httpWebRequest:

    class Interact
	{
		<data, cookies, etc>
		
		HttpWebRequest CreateWebRequest(...)
		{
			.....
		
				request.ServicePoint.BindIPEndPointDelegate = delegate(
				ServicePoint servicePoint,
				IPEndPoint remoteEndPoint,
				int retryCount)
						  {
							  if (lastIpEndpoint!=null)
							  {
								  return lastIpEndpoint;
							  }
							  var candidates =
								  GetAddresses(remoteEndPoint.AddressFamily);
							  if (candidates==null||candidates.Count()==0)
							  {
								  throw new NotImplementedException();
							  }

							  return
								  lastIpEndpoint = new IPEndPoint(candidates[rnd.Next(candidates.Count())],0);
						  };
				};
				
			return request;
		}
 
		static IPAddress[] GetAddresses(AddressFamily af)
        {
            System.Net.IPHostEntry _IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
            return (from i in _IPHostEntry.AddressList where i.AddressFamily == af select i).ToArray();
        }
	}

    


This code is supposed to select a random IP from avaliable IP list, and than stick to it.

Instead, every time I send request with it, I'm getting following exception:

`Unable to connect to the remote server`

How do I make this work?