c# - windows mobile 6.5 .net CF HttpWebRequest to same URL from 2 different threads - errors -


i have strange situation in .net cf 3.5 windows mobile 6.5 application. have 2 threads.

in 1st thread following:

try {   string url = "http://myserverurl";   httpwebrequest request = (httpwebrequest)webrequest.create(url);   _currentrequest = request;   request.timeout = 10000;    response = (httpwebresponse)request.getresponse();   connectionstatus connstatus = response.statuscode == httpstatuscode.ok;   response.close(); } catch (exception e) {    //log e } {  } 

in 2n thread call webservice through soaphttpclientprotocol based class generated webservice reference.

soapclient.url = "http://myserverurl"; soapclient.methodonwebservice(); 

in both cases url same. 1st thread used connection checking purpose. webrequest periodically check whetrher server available , displays connection status (not shown in code). 2nd thread calls webservice on same server (url). observed, when 1 thread executing webrequest 2nd 1 gets blocked or event timeouted while executing web method. both interfering each other. why? wonder if windows mobile network stack creates 1 socket connection both threads if realizes both goes same target ip:port? sessions? on desktop windows expect 2 sessions being created , @ least 2 sockets on client machine. have hints on how windows mobile (or .net cf) manages connections , socket reusage?

regards

i guess there third session somewhere. you're seeing due little-known (until bites you, now) recommended connection-limitation in http-protocol. section 8.1.4 of rfc2068 says "a single-user client should maintain @ 2 connections server or proxy". i've experienced same limitation myself, on windows phone 7.

the limit lies in webrequest , solution increase limit:

// set connection limit 5 servicepointmanger.defaultconnectionlimit = 5; 

see e.g. old blog entry david kline.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -