I've searched all over on how to use BindIPEndPointDelegate to change the source port of my HttpWebRequest. I have found multiple posts on this:
However, It doesn't seem to be working for me. I found the same issue with this guy: Define Outgoing/Calling Port for SOAP Web Service in Visual Studio 2010
Basically, I want to change my source port when connecting to a webpage. BindIPEndPointDelegate is pretty straigh forward.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.ServicePoint.BindIPEndPointDelegate = (servicePoint, remoteEp, retryCount) =>
{
return new IPEndPoint(IPAddress.Any, 8086);
};
When I look at the connections with netstat -n, I expect to see myipaddress:8086 as the source and the destination IP:80. What I see in netstat is that it is creating a loopback (127.0.0.1:8086) with my specified port. See screen shot of netstat -n
Since this is my first post, I can't post images. So the image can be found here
Why does BindIPEndPointDelegate create a loop back connection and how can I get my WebRequest to behave like the browser with my specified port?
I'm on a win7 Pro box, No local firewall, Not going through a proxy.