use Socket; my @test=('yahoo.com','whois.networksolutions.com','165.247.62.62'); sub whoislookup2{ my($domain,$server,$ip) = @_; my(@test,$sin); socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp')) or return undef; # This builds the address of the remote machine, to be used in the connect my $remote_host=inet_aton($server) or return undef; $sin = sockaddr_in(43, $remote_host); # This builds the address of the local machine, to be used for binding the client to a specific IP (this program) my $local_host=inet_aton($ip) or return undef; my $local = sockaddr_in(43, $local_host); bind(SOCK,$local) or print 'Couldn\'t bind to local\n'; connect(SOCK, $sin) or return undef; select((select(SOCK),$| =1)[0]); #This enables buffering on SOCK print SOCK "$domain\n"; @test= or return undef; close(SOCK) or return undef; return @test; }