Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: built-in socket functions

by Anonymous Monk
on Oct 25, 2012 at 02:33 UTC ( #1000751=note: print w/replies, xml ) Need Help??

in reply to built-in socket functions

What kind of socket do you have?

Doesn't SO_SNDTIMEO require blocking sockets?

Why aren't you error checking?

setsockopt ... or die Fudge("SO_SNDTIMEO"); setsockopt ... or die Fudge("SO_RCVTIMEO"); sub Fudge { use Errno(); join qq/\n/, "Error @_", map { " $_" } int( $! ) . q/ / . $!, int( $^E ) . q/ / . $^E, grep( { $!{$_} } keys %! ), q/ /; }

Replies are listed 'Best First'.
Re^2: built-in socket functions
by tenny1204 (Novice) on Oct 25, 2012 at 04:28 UTC

    I tried errorchecking but no error, doesn't even seem to matter what i write after pack().I have something like:

    $port=80; $proto=getprotobyname('tcp'); socket(SOCKET,AF_INET,SOCK_STREAM,$proto) or die "no socket"; setsockopt(SOCKET,SOL_SOCKET,SO_RCVTIMEO,pack("LL",1,0)); $iadr = inet_aton(""); $padr=sockaddr_in($port,$iadr); if(connect(SOCKET,$padr)){ print "connection ok";} else{print "$!\n";}

    It should correspond to something like:

    $conn = IO::Socket::INET->new( PeerAddr=>"", PeerPort=>80, Proto=>'tcp', Timeout=> 1, Blocking=>1 );

    So: a blocking socket with a 1 second timeout because now the standardtimeout is something like 10 seconds,making my applications run slower iso faster which was the general idea.

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

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.

      RIP Neil Armstrong

        I allready looked at that, says on windows SO_RCVTIMEO is considered to be a DWORD, but i cannot find any documentation on how to pack a DWORD, so i keep getting stuck. I thought maybe it would be something simple, cause it doesn't take much effort if you're using the IO::Socket module. But nevermind, I'll work something out. Thank you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000751]
and monks are getting baked in the sun...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-12-14 13:23 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (394 votes). Check out past polls.