Im trying to learn perl socket without the OO approach.

My get request isnt working, im not sure why.
Take a look?

#!/usr/bin/perl

use IO;
use Socket;


socket(SOCKFD,AF_INET,SOCK_STREAM,getprotobyname("tcp")) || die "Socket Error\n";

$host = gethostbyname("www.google.com");

$addr = sockaddr_in(80,$host);

connect(SOCKFD,$addr) || die "Connect Error\n";

print SOCKFD "GET /";

while(<SOCKFD>){
    print $_;
}

My get request isnt working

What does that mean? Not working means millions of things... Have to taken a look at Socket doc?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.