Subject: | It appears new_from_socket might not work at all |
I've been reviewing IO::Socket::Socks for use in Mojolicious and stumbled over some things. It appears new_from_socket is untested and may not work at all. To demonstrate the problem i've modified the non-blocking documentation example and attached it to this ticket.
P.S.: Installing IO::Socket::Socks on OS X is really really hard.
--
sebastian
Subject: | test.pl |
use IO::Socket::INET;
use IO::Socket::Socks;
use IO::Select;
my $sock = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => 9050);
$sock->blocking(0);
$sock = IO::Socket::Socks->new_from_socket(
$sock,
ConnectAddr => 'mojolicio.us',
ConnectPort => 80,
Blocking => 0,
SocksDebug => 1
) or die $SOCKS_ERROR;
my $sel = IO::Select->new($sock);
until ($sock->ready) {
if ($SOCKS_ERROR == SOCKS_WANT_READ) {
$sel->can_read();
}
elsif ($SOCKS_ERROR == SOCKS_WANT_WRITE) {
$sel->can_write();
}
else {
die $SOCKS_ERROR;
}
}
# you may want to return socket to blocking state by $sock->blocking(1)
$sock->syswrite("I am ready");