PC Review


Reply
Thread Tools Rate Thread

Multithreaded HTTP requests

 
 
Christopher Marshall
Guest
Posts: n/a
 
      2nd Feb 2004
Hi Chaps,

I'm trying to make repeated requests to a web service asyncronously so
the server can deal with the requests while the client does another
task, then the client can pick up the responses.

However when I access any server other than localhost the app only
ever returns two responses (this doesn't matter if I point it at my
web service or a public page like "http://www.microsoft.com"; it,
seemingly, only returns two wherever it is in the world). On
localhost it returns as many requests as are needed. RequestState is
from http://msdn.microsoft.com/library/de...usRequests.asp

Does anyone know what could be causing this?

Thanks for your help - Christopher


private void button1_Click(object sender, System.EventArgs e)
{
for ( int iRequestNumber = 0;
iRequestNumber < numRequests.Value;
iRequestNumber ++ )
{
string sURL = textBox2.Text;
HttpWebRequest httpRequest =
(HttpWebRequest) WebRequest.Create( sURL );
RequestState oRS = new RequestState();
oRS.Request = httpRequest;
oRS.m_oHostForm = this;
IAsyncResult ar = httpRequest.BeginGetResponse(
new AsyncCallback( reqCallBack ), oRS );
}
}

private static void reqCallBack( IAsyncResult ar )
{
RequestState oRS = (RequestState) ar.AsyncState;
WebRequest oReq = oRS.Request;
oRS.m_oHostForm.setOutput( "received response " +
oRS.GetHashCode().ToString() );
}
 
Reply With Quote
 
 
 
 
Magne Ryholt
Guest
Posts: n/a
 
      3rd Feb 2004
The referred article says:
Note It is critical that all network streams are closed. If you do not
close each request and response stream, your application will run out of
connections to the server and be unable to process additional requests.

Have you closed the response stream (default there is only two connections)
?
"Christopher Marshall" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Chaps,
>
> I'm trying to make repeated requests to a web service asyncronously so
> the server can deal with the requests while the client does another
> task, then the client can pick up the responses.
>
> However when I access any server other than localhost the app only
> ever returns two responses (this doesn't matter if I point it at my
> web service or a public page like "http://www.microsoft.com"; it,
> seemingly, only returns two wherever it is in the world). On
> localhost it returns as many requests as are needed. RequestState is
> from

http://msdn.microsoft.com/library/de...usRequests.asp
>
> Does anyone know what could be causing this?
>
> Thanks for your help - Christopher
>
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> for ( int iRequestNumber = 0;
> iRequestNumber < numRequests.Value;
> iRequestNumber ++ )
> {
> string sURL = textBox2.Text;
> HttpWebRequest httpRequest =
> (HttpWebRequest) WebRequest.Create( sURL );
> RequestState oRS = new RequestState();
> oRS.Request = httpRequest;
> oRS.m_oHostForm = this;
> IAsyncResult ar = httpRequest.BeginGetResponse(
> new AsyncCallback( reqCallBack ), oRS );
> }
> }
>
> private static void reqCallBack( IAsyncResult ar )
> {
> RequestState oRS = (RequestState) ar.AsyncState;
> WebRequest oReq = oRS.Request;
> oRS.m_oHostForm.setOutput( "received response " +
> oRS.GetHashCode().ToString() );
> }



 
Reply With Quote
 
Christopher Marshall
Guest
Posts: n/a
 
      3rd Feb 2004
Great!! Thanks for the info that was realy helpfull.

- Christopher


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is a simulated HTTP requests? Marvin Landman Microsoft ASP .NET 4 25th Nov 2009 03:06 AM
Getting HTTP 400 errors with multithreaded webservice calls through an authenticating ISA proxy JohnH Microsoft Dot NET Framework 0 1st Aug 2007 12:29 AM
Redirecting HTTP Requests to SSL Requests =?Utf-8?B?TmlrcmVw?= Microsoft Outlook Installation 0 29th Aug 2005 11:19 PM
Re: Looking for advise: Multithreaded http requests Eliyahu Goldin Microsoft ASP .NET 0 21st Sep 2004 04:06 PM
Problem with http requests Mike Microsoft Windows 2000 2 27th Aug 2003 03:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 AM.