in reply to Re: how to set socket recv timeout in architecture independent manner?
in thread how to set socket recv timeout in architecture independent manner?

Thanks. But if you read the first post of this thread, I have used sockopt and I wanted to do this in an architecture independent manner. Read the follow ups to know how it was accomplished with valuable inputs from the monks.
  • Comment on Re^2: how to set socket recv timeout in architecture independent manner?

Replies are listed 'Best First'.
Re^3: how to set socket recv timeout in architecture independent manner?
by BrowserUk (Patriarch) on May 06, 2009 at 17:45 UTC

    Well okay, I'm glad you got what works for you, but ... in your orignal post you asked for how to

    set recv timeout ... architecture independent way

    That generally means there are two problems to solve:

    1. Are the system functions available to do X.

      And ignoring obscure little used platforms, that usually divides into POSIX and Win platforms. As setsockopt is a POSIX core function that takes care of most places. My post was to show you that it is available on windows also.

    2. Passing architecture-dependant binary values.

      By using a '!L', you get an architecture independant way of native longs.

    Whilst using select and can_read() with timeout achieves a similar goal, you are substituting a 'polling' solution for a timer solution (at least in some platforms), and that can significantly increase you cpu usage.

    In addition, using select imposes a particular architecture--which is often unnatural--upon your application. If your happy with that, then great, but I thought the alternative worth a mention.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.