  | |  | Async LoadVars > 2 Connection Limit HTTP 1.1 | Async LoadVars > 2 Connection Limit HTTP 1.1
2004-02-18 - By Ashley Rajaratnam
Back Hi All -
This is a follow-up from my previous posting about asynchronous Loadvars
calls. I thought I 'd post the answer and save anyone else out there
having to figure it all out again!
Here is the sample actionscript code to demonstrate the problem:
-The server ASP page pause 10 seconds then gives a result back.
-You 'll a textfield on a stage instanced res_txt.
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
_global.callHost = function(callerid) {
res_txt.text = res_txt.text +newline+ ( "callHost "+callerid);
var objLoadVars;
objLoadVars = new LoadVars();
objLoadVars.returnID = callerid;
objLoadVars.onLoad = function(success) {
res_txt.text = res_txt.text +newline+ ( "call host
1 "+success+objLoadVars.returnID);
if(success){
_global.hostResult(objLoadVars);
} else {
_global.hostResult(objLoadVars);
}
}
//send and load the data
objLoadVars.sendAndLoad(( "http://testplay.server.com/pause10seconds.asp "
),objLoadVars, "GET ");
}
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
_global.hostResult = function(objRet) {
var variable;
for(variable in objRet){
//res_txt.text = res_txt.text +newline+ "HOST RESULT 1
variable: "+variable+ " value: "+objRet[variable];
}
}
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
for (i=0;i <6;i++) {
_global.callHost(i);
}
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
Now run the thing you 'll notice that only two calls get fired off at a
time.
Check the web logs from your webserver and you 'll see something like
this:
2004-02-18 12:52:23 GET /pause10seconds.asp
2004-02-18 12:52:23 GET /pause10seconds.asp
2004-02-18 12:52:33 GET /pause10seconds.asp
2004-02-18 12:52:33 GET /pause10seconds.asp
2004-02-18 12:52:43 GET /pause10seconds.asp
2004-02-18 12:52:43 GET /pause10seconds.asp
Notice the time (seconds.)
This happens using all browsers because of HTTP 1.1 specification
(RFC2068) which mandates a two-connection limit. You can override this
in IE by setting some registry values:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.
com:80/support/kb/articles/q183/1/10.asp&NoWebContent=1
Obviously not practical for the web...
If anyone is interested Ive written and extension to the LoadVars object
to queue requests also allowing you to set priority levels on calls in
order to simulate true unlimited asynchronous calls and let you control
the order and amount of host calls
If anyone is interested Ill post it
Cheers ash
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:104586
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |