Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have two wireless network adapters connected to my computer, each connected to a different network. I would like to build a kind of proxy server that my browser would connect to and it will send HTTP requests each from different adapter so loading time on webpages would be smaller. Do you guys know how can I decide from which network adapter to send the HttpWebRequest?

Thanks :)

UPDATE

I used this code:

public static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
{
    List<IPEndPoint> ipep = new List<IPEndPoint>();
    foreach (var i in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
    {
        foreach (var ua in i.GetIPProperties().UnicastAddresses)
            ipep.Add(new IPEndPoint(ua.Address, 0));
    }
    return new IPEndPoint(ipep[1].Address, ipep[1].Port);
}

private void button1_Click(object sender, EventArgs e)
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://whatismyip.com");
    request.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(BindIPEndPointCallback);
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader sr = new StreamReader(response.GetResponseStream());
    string x = sr.ReadToEnd();
}

But even if a change the IPEndPoint I send the IP I get from WhatIsMyIp is still the same.. any help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
395 views
Welcome To Ask or Share your Answers For Others

1 Answer

BindIPEndPointDelegate may well be what you're after here. It allows you to force a particular local IP to be the end-point via which the HttpWebRequest is sent.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...