PC Review


Reply
Thread Tools Rate Thread

How to control TCP/IP connections used with HttpWebRequest ?

 
 
Jacek
Guest
Posts: n/a
 
      20th Jul 2005
Hi All!

After checking with packet sniffer that for every created HttpWebRequest /
HttpWebResponse followed by Close() call my box creates new TCP/IP
connection I just wonder if there is a way to use single long lasting TCP/IP
connection with a given server for multiple HttpWebRequest / HttpWebResponse
operations.

Any ideas?


 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      20th Jul 2005
Jacek wrote:

> Hi All!
>
> After checking with packet sniffer that for every created
> HttpWebRequest / HttpWebResponse followed by Close() call my box
> creates new TCP/IP connection I just wonder if there is a way to use
> single long lasting TCP/IP connection with a given server for
> multiple HttpWebRequest / HttpWebResponse operations.
>
> Any ideas?


Can you post some code? Reusing a TCP connection is what persistent
connections in HTTP 1.1 (or keep-alive in 1.0) are all about, and these
features are all implemented by HttpWebRequest.

Cheers,

--
http://www.joergjooss.de
mailto:news-(E-Mail Removed)
 
Reply With Quote
 
Feroze [msft]
Guest
Posts: n/a
 
      22nd Jul 2005
By default, HttpWebRequest tries to use persistent connections. Now, if the
server is closing the connection after each request, then the client will be
forced to create a new one.

Also, are you tweaking any connection related properties on the webrequest
object, like: KeepAlive, ConnectionGroupName etc? Depending on what you set
there, it might affect connection reuse also

To answer your question, setting request.KeepAlive=true causes connection to
be reused.
--
feroze

-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.

See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------

"Joerg Jooss" <news-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Jacek wrote:
>
>> Hi All!
>>
>> After checking with packet sniffer that for every created
>> HttpWebRequest / HttpWebResponse followed by Close() call my box
>> creates new TCP/IP connection I just wonder if there is a way to use
>> single long lasting TCP/IP connection with a given server for
>> multiple HttpWebRequest / HttpWebResponse operations.
>>
>> Any ideas?

>
> Can you post some code? Reusing a TCP connection is what persistent
> connections in HTTP 1.1 (or keep-alive in 1.0) are all about, and these
> features are all implemented by HttpWebRequest.
>
> Cheers,
>
> --
> http://www.joergjooss.de
> mailto:news-(E-Mail Removed)



 
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
HttpWebRequest and Reusing Connections Mike Microsoft Dot NET Framework 1 11th Jun 2010 09:48 AM
HttpWebRequest and Reusing Connections Mike Microsoft ASP .NET 1 11th Jun 2010 09:48 AM
HttpWebRequest and Reusing Connections Mike Microsoft Dot NET Framework Forms 1 11th Jun 2010 09:48 AM
How to limit HttpWebRequest connections? Basel Microsoft C# .NET 10 25th May 2006 11:19 PM
HttpWebRequest/Response Timeouts and Connections Steve Binney Microsoft Dot NET Framework 2 27th Sep 2003 05:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:52 AM.