I have been trying the following code....
#!bin/perl
use IO::Socket;
my $host = 'my $port = 80;
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket :$!";
$H2 = "GET /index.html\r\n";
open(LOG1, "> web_resp.log") || die print "Can't open log$!\n";
# Set socket to be command buffered.
print $sock "$H2";
select($sock); $| = 1;
read($sock, $buf, 500);
# Now we're connected to the server, let's read the host response
print LOG1 "$buf\n";
#Closing the socket
close $sock;
close(LOG1);
But the problem is that the script hangs and does not respond. What might be wrong? The script does not even throw any errors.
Also want to know if I had to send 10 such parallel requests how would I modify the above. The problem is that, sending the request in a loop would immulate only sequential requests being sent. But to send 10 parallel requests what would I have to do?
#!bin/perl
use IO::Socket;
my $host = 'my $port = 80;
my $sock = new IO::Socket::INET( PeerAddr => $host, PeerPort => $port, Proto => 'tcp');
$sock or die "no socket :$!";
$H2 = "GET /index.html\r\n";
open(LOG1, "> web_resp.log") || die print "Can't open log$!\n";
# Set socket to be command buffered.
print $sock "$H2";
select($sock); $| = 1;
read($sock, $buf, 500);
# Now we're connected to the server, let's read the host response
print LOG1 "$buf\n";
#Closing the socket
close $sock;
close(LOG1);
But the problem is that the script hangs and does not respond. What might be wrong? The script does not even throw any errors.
Also want to know if I had to send 10 such parallel requests how would I modify the above. The problem is that, sending the request in a loop would immulate only sequential requests being sent. But to send 10 parallel requests what would I have to do?