zwon has asked for the wisdom of the Perl Monks concerning the following question:

I want to set SO_RCVTIMEO option for a socket, but a problem is that underlying syscall wants struct timeval and depending on architecture it may be couple of 32-bit or 64-bit integers. So I can use

$socket->sockopt(SO_RCVTIMEO, pack('LL', $seconds, 0));
on 32-bit or
$socket->sockopt(SO_RCVTIMEO, pack('QQ', $seconds, 0));
on 64-bit.

My question is what is the way to determine if script run on 32-bit or 64-bit OS, and if there's a better way to create this structure?

Replies are listed 'Best First'.
Re: setting timeout for a socket
by BrowserUk (Patriarch) on May 16, 2011 at 04:32 UTC

    c:\test>\perl32\bin\perl.exe -V:ptrsize ptrsize='4'; c:\test>\perl64\bin\perl.exe -V:ptrsize ptrsize='8'; c:\test>perl -MConfig -wE"say $Config{ptrsize}" 8 c:\test>\perl32\bin\perl.exe -MConfig -le"print $Config{ptrsize}" 4

    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.

      Thanks that will do, I looked on Config, but searched for wrong words.