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

PerlSufi's scratchpad

by PerlSufi (Friar)
on Mar 26, 2013 at 21:02 UTC ( #1025584=scratchpad: print w/ replies, xml ) Need Help??

#! /usr/bin/perl use IO::Socket::SSL; use Socket; # For constants like AF_INET and SOCK_STREAM use IO::Select; $proto = getprotobyname('tcp'); #get the tcp protocol # 1. create a socket handle (descriptor) my($sock); socket($sock, AF_INET, SOCK_STREAM, $proto) or die $!; # 2. connect to remote server $remote = ''; $port = 443; $iaddr = inet_aton($remote) or die "Unable to resolve hostname : $remo +te"; $paddr = sockaddr_in($port, $iaddr); #socket address structure connect($sock , $paddr) or die "connect failed : $!"; print "Connected to $remote on port $port\n"; #$answer = <$sock>; #while(<$sock>){ sysread ($sock); print $answer;} my $buf = ''; my $header; for (;;) { my $rv = sysread($sock, $buf, BLK_SIZE, length($buf)); die("Can't read: $!\n") if !defined($rv); die("Can't read: Premature EOF\n") if !$rv; if ($buf =~ s/^(.*\r\n\r\n)//s) { $header = $1; last; } }
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (16)
As of 2014-10-24 18:27 GMT
Find Nodes?
    Voting Booth?

    For retirement, I am banking on:

    Results (134 votes), past polls