Home All Groups Group Topic Archive Search About

Specifying Source IP of HttpWebRequest

Author
2 Nov 2005 12:41 PM
uncaged
I’ve created an HttpClientConnection class which handles HTTP requests from
one IP address and port number to one URL.  I plan on having many (about
1,000) instances of this class, each associated with one of the many IP
addresses that will be on one NIC card.  They will all be sending requests to
the same URL, but that server must be able to distinguish requests by the IP
address that sent them.

I understand how to use the BindIpEndPoint callback to set the IP address
and port number of a single request, but since it must be a static function,
and since the arguments to the callback function refer to the target URL and
not the source, and don't let me supply an argument for the callback, I don’t
see how to handle the callback when many requests are happening
simultaneously.

It appears that the BindIpEndPoint callback is called before the
BeginGetResponse callback gets called for the GET method, and before the
BeginGetRequestStream callback gets called for the POST method.  If I have
to, I’ll use a static mutex to allow only one instance to be in that waiting
period between a Begin… and the callback, but that doesn’t sound like a good
idea.

Any help you can get me in this matter would be greatly appreciated.

AddThis Social Bookmark Button