I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2006-03-03 19:38:35-08 by sununixoid
How to work with socks proxies on PERL?
I have a problem including Socks.pm I love perl but sometimes it makes me mad: Why static include is such a complicated task?? imporing is such a simple thing in python: write down import foo and foo serached in this dir

I need to work with socks proxies, since did not support them i have to do though socket stuff. I am not a professional in SOCKS headers and authentifications to write directly to socket so to go through connection stage as simple as possible
i have downloaded IO::Socket::Socks and of course hosting provider don`t have that module. And so my journey on google beginned i surfed 2 days but nothing.

Here is what i did to staticaly include Socks.pm:
1. I placed Socks.pl in "/var/www/html/test/jester/proxy/socks"
and the running script also lies there
2. Writed down this in script
use lib qw(/var/www/html/test/jester/proxy/socks);
this line seems adding "/var/www/html/test/jester/proxy/socks" to the top of the @INC;

#!/usr/bin/perl -W use strict; use lib qw(/var/www/html/test/jester/proxy/socks); use IO::Socket::Socks; #use Socks; my $socks = new IO::Socket::Socks(ProxyAddr=>"XX.XXX.XX.XX", ProxyPort=>"1080", ConnectAddr=>"google.com", ConnectPort=>"80", ); print $socks "foo\n"; $socks->close();

The code above gives an error:
BEGIN failed--compilation aborted at ./goof.pl line 7
if uncomment use Socks and comment IO::Socket::Socks; like this:
use Socks; my $socks = new IO::Socket::Socks(ProxyAddr=>"XX.XXX.XX.XX", ProxyPort=>"1080", ConnectAddr=>"google.com", ConnectPort=>"80", ); print $socks "foo\n"; $socks->close();
this code above throws at start up (because $socks is somehow undef):
Can't use an undefined value as a symbol reference at ./goof.pl line 15.
I tryed a whole bunch of variations like:
use Socks; my $socks = IO::Socket::Socks->new
use IO::Socket::Socks; my $socks = new IO::Socket::Socks

I think the problem lies inside the Socks.pm , here is a piece of source code of Socks.pm:
# sub new is handled by IO::Socket::INET
new sub handled by IO::Socket::INET !!!!!!!!!!
How i can make them work together??
Could anyone give me a clue how to work with SOCKS proxies in perl?
I can open socket but i am a newbie in sockets and SOCKS protocols
simple GET on HTTP proxy works fine but when connecting SOCKS proxy
it seems you must send haeder including version,Auth_type,dest ....
i dont know how to send this header and pack...

So how to work with socks proxies on PERL???


Direct Responses: Write a response