I do not have any sample code for this.
There are two ways to send requests in parallel:
1) Create separate worker threads and have each thread send a synchronous
HTTP request to one of the servers. Or instead of creating your own threads,
you can use the system thread pool with the QueueUserWorkItem Win32 API.
2) Use WinInet in asynchronous mode and dispatch the multiple requests from
your main client thread. WinInet will use the system thread pool to process
the requests concurrently.
In each case, once one of the requests has received a response, you can then
abort the other requests (or just let them finish and ignore/discard the
responses they receive). You need to decide at what point a request has
received a response and should tell the other requests to abort. For
example, when all of the response data has been received? Or, when the first
part of the response data has been received? Or when just the HTTP response
headers have been received? If you do not expect a large response, then it
does not matter how you decide this.
Both solutions involve multi-threaded programming, which you need to
understand. You will need a global flag (with synchronized write access
using InterlockedIncrement, for example) that is set once one of the
requests has received a response. Each request can use this flag to see if
some other request has finished already, and if so, it can then abort itself
(by closing its WinInet request and connect handles) and discard any
response data it has received.
Solution #1 is probably easier to implement (since using WinInet in
asynchronous mode can be difficult). It is also important to point out that
WinInet should only be used in a single-user application. Do not use WinInet
in any kind of multi-user, server-based application, such as a proxy server
or within an ISAPI component. For server-based applications, use WinHTTP
instead.
If you try solution #2, and you are not familiar with using WinInet in
asynchronous mode, then read the following documentation to help get you
started:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/asynchronous_operation.asp
Good luck.
Stephen