0

How do I re-use the sockets in HttpWebRequest if I want to send a lot of requests fast? Right now it sends the requests at between 300ms to 800ms. And I re-declare my HttpWebRequest in each call

Is this even possible? I noticed making my own GET requests using a TCPClient was a lot faster but it was too much hassle implementing https/ssl

CodingGorilla
  • 19,612
  • 4
  • 45
  • 65
Ragnar Olsen
  • 56
  • 1
  • 7
  • 1
    [If keep-alive is on, then .NET will keep the socket connection open under the hood and reuse it for the next request for the same domain](http://stackoverflow.com/questions/4933450/can-i-reuse-httpwebrequest-without-disconnecting-from-the-server). [It will also reuse the TLS session](http://stackoverflow.com/questions/24202530/how-to-reuse-connection-request-to-avoid-handshake). Please do more analysis to pinpoint the actual source of the slowness. – CodeCaster May 06 '16 at 12:20
  • Other than what @CodeCaster caster said, the answer is no; you don't own the socket and it's totally under the control of `HttpWebRequest` so you can't re-use it. – CodingGorilla May 06 '16 at 12:22

0 Answers0