Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

PerlSufi's scratchpad

by PerlSufi (Pilgrim)
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 = '23.56.135.7'; $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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-10-01 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (386 votes), past polls