Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: how to set socket recv timeout in architecture independent manner?

by robnewton (Initiate)
on Jun 15, 2009 at 23:03 UTC ( [id://771822]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://771822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2025-03-26 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (67 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.