CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: timeout on recv

  1. #1
    Join Date
    Oct 2007
    Posts
    36

    timeout on recv

    i make a project where i need to download web pages.
    my problem was how would i recv the hole web page. the content length part of the HTTP header isn't always set so it's not a trusted source. if i was receiving while there were bytes coming the recv call would freeze when there where no more bytes until some new traffic come. So i added a timeout of 5sec to recv.
    my question is :
    is it safe to put the timeout on lower values such as 1 sec or even lower or there is a chance that recv will miss some part of the incoming bytes maybe due to bandwidth difference or any other reason?
    Thanx in advance.
    Last edited by verbal; January 18th, 2008 at 10:49 AM.

  2. #2
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: timeout on recv

    It's all a matter of engineering trade-offs. A 1 second time-out might work fine for many systems, and it also might be too fast for many others. You need to experiment, learn the limitations, and make certain that the end-user knows and understands them.

    Mike

  3. #3
    Join Date
    Oct 2007
    Posts
    36

    Re: timeout on recv

    i made the timeout as a configuration option and let it up to the user (along with some warnings on the documentation and the default value on 5s).
    After some tests i ran at random servers i found that there can be a huge gap on the appropriate timeout. some servers where responding very well with a very small timeout and others had problems with the timeout on 10sec or bigger. i didn't expect such a big gap.

  4. #4
    Join Date
    Dec 2007
    Posts
    30

    Re: timeout on recv

    yes,you can set timeout to be less than 1 sec or even less,but it is up to your scenario.
    Best,
    Kevin Jo
    http://www.upredsun.com
    **Easily and automatically build tcp-based or udp-based network protocol source code**

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured