http://www.perlmonks.org?node_id=771822


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?

Great, your suggestion to use the '!' modifier in pack() made my code work for 32 and 64-bit platforms. However, the '!' must come AFTER the 'L', giving:

 setsockopt( $client, SOL_SOCKET, SO_RCVTIMEO, pack('L!L!', +10, 0) );

  • Comment on Re^2: how to set socket recv timeout in architecture independent manner?
  • Download Code

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

    I guess another way to tackle the problem using pure Perl internals would be setting an alarm for the recv operation. This may not be most elegant piece of code but can solve a quick script.

    Just FYI I am using Cygwin and SO_RCVTIMEO does not work very good. I am on winXP (32bit) and tried ll, LL, qq, QQ

      Did you try 'VV'?


      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.

        I just tried VV and NN but fails again, do you know what time of machine Cygwin is emulating?

        I am not to concern since my scripts will run under Solaris but all my dev is done on a Win based PC. Thanks anyways