Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Non-blocking socket win32 not work with IO::Socket::SSL

by Viperii (Initiate)
on Mar 28, 2008 at 01:33 UTC ( [id://676887]=perlquestion: print w/replies, xml ) Need Help??

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

I use this code to make 'REAL' timeout connection on Windows, it works fine with IO::Socket::INET, but got "400 Bad Request" response with IO::Socket::SSL.
#! perl -w use strict; use IO::Socket; use IO::Socket::SSL; use IO::Select; my $timeout = 3; my $socket = IO::Socket::SSL->new( Proto => "tcp", Type => SOCK_STREAM); ioctl($socket, 0x8004667e, pack("I", 1)); # Good HTTPS server response + with comment this, but timeout not work. my $inetaddr = inet_aton("some_ssl_host"); my $peeraddr = sockaddr_in(443, $inetaddr); $socket->connect($peeraddr); $socket->autoflush; my $select = new IO::Select($socket); if($select->can_write($timeout)) { my $req = "GET /index.php HTTP/1.0\n\n"; print $socket $req; print <$socket>; # Got "400 Bad Request" from HTTPS server. } else { print "Connect timeout.\n"; } close $socket; exit;
So, how to make a workable timeout connection with IO::Socket::SSL on win32? Thanks all!
http://hominidhe.blog.163.com/

Replies are listed 'Best First'.
Re: Non-blocking socket win32 not work with IO::Socket::SSL
by Anonymous Monk on Mar 28, 2008 at 08:46 UTC
    Try IO-Socket-SSL-1.13_5
      With Perl 5.10 and IO-Socket-SSL 1.13,
      C:\Documents and Settings\Administrator>perl -MIO::Socket::SSL -e "pri +nt $IO::Socket::SSL::VERSION" 1.13 C:\Documents and Settings\Administrator>perl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread
      I can use blocking(0) directly:
      #ioctl($socket, 0x8004667e, pack("I", 1)); $socket->blocking(0);
      but "print <$socket>" output garbled characters, and HTTPS server got no request.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-04-24 10:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found