And overrided connect() function looks like this now:sub new_from_socket { my ($class, $sock, %arg) = @_; bless $sock, $class; $sock->autoflush(1); ${*$sock}{'io_socket_timeout'} = delete $arg{Timeout}; return scalar(%arg) ? $sock->configure(\%arg) : $sock; }
First tests shows that it works both with simple sockets and with IO::Socket::INET objects.use Socket; BEGIN { *CORE::GLOBAL::connect = sub(*$) { my ($socket, $name) = @_; return CORE::connect($socket, $name) if (scalar(caller 2) eq ' +IO::Socket::Socks'); my ($port, $host) = sockaddr_in($name); $host = inet_ntoa($host); my $ref = ref($socket); IO::Socket::Socks->new_from_socket( $socket, ProxyAddr => 'localhost', ProxyPort => 1080, SocksVersion => 5, ConnectAddr => $host, ConnectPort => $port, #SocksDebug => 1 ) or return undef; bless $socket, $ref if $ref; return 1; } } use IO::Socket::Socks;
In reply to Re: Typeglob substitution in objects based typeglob
by OlegG
in thread Typeglob substitution in objects based typeglob
by OlegG
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |