Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Force request to specific IP address and port
string sendingIp = "";
int sendingPort = 5000;
Uri uri = new Uri("");
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(uri);
ServicePoint sp = ServicePointManager.FindServicePoint(uri);
sp.BindIPEndPointDelegate =
(servicePoint,remoteEp,retryCount) =>
return new IPEndPoint(IPAddress.Parse(sendingIp),sendingPort);
var data = new StreamReader(wr.GetResponse().GetResponseStream()).ReadToEnd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.