Using BindIPEndPointDelegate to specify the source port does not work

I searched all about how to use BindIPEndPointDelegate to change the source port of my HttpWebRequest. I found some posts on this subject:

Here and here

However, it does not seem to work for me. I found the same problem with this guy: Define outgoing / calling port for SOAP web service in Visual Studio 2010

Basically, I want to change the source port when connecting to a web page. BindIPEndPointDelegate is pretty advanced.

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.ServicePoint.BindIPEndPointDelegate = (servicePoint, remoteEp, retryCount) => { return new IPEndPoint(IPAddress.Any, 8086); }; 

When I look at connections with netstat -n, I expect to see myipaddress: 8086 as the source and destination IP address: 80. What I see in netstat is that it creates a loopback (127.0.0.1:8086) with my specified port. See screenshot netstat -n

Since this is my first post, I can not send images. So the image can be found here

Why is BindIPEndPointDelegate creating a feedback connection and how can I make my WebRequest behave like a browser with my specified port?

I am in a win7 Pro window, without a local firewall, without missing a proxy.

+4
source share
1 answer

I had a similar problem today. I selected a specific source port in BindIPEndPointDelegate, but with WireShark I always saw a different source port than the one I selected. Then I discovered that I was implicitly using a proxy server using the Fiddler2 Web Debugger . As soon as I turned off Fiddler, I started to see the source port numbers in WireShark that I requested in the Bind delta.

The result is that if you have a proxy server, you can see the same behavior.

0
source

All Articles