Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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/ /; }


Comment on Re: built-in socket functions
Download Code
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("127.0.0.1"); $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=>"127.0.0.1", 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-08-21 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (135 votes), past polls