HI monks!

I have one question to you: what is the best way, how to check if server on some port is proxy, or socks server ? I wrote perl script for that, where I'm checking, if the port is open, if yes, I'm testing if it is proxy or socks. OK, but not that is my problem. I don't know how I can define timeout for socks5 connection, sometimes it connects around minute or more! I also tried add Timeout to Net\SOCKS.pm, but no luck. Do you think using alarm is good idea for that ? I'm not sure, so I'm asking you for your wisdom. I tried that on AS perl, and also on FreeBSD machine, so it is not windows related I guess. Thanks for any idea, how to fix that. Also I tried IO::Socket::Socks, it has the same behavior :(

use strict; use warnings; use URI; use IO::Socket; use Net::SOCKS; #my $server = '68.34.100.143:29992'; #works #my $server = '68.48.32.219:38884'; #opens, but no content my $server = '217.237.150.97:80'; #no timeout !?! my ($ip, $port) = ($1, $2) if $server =~ /([^:]+):(.*)/; my $page = URI->new('http://www.2ge.us/index.html'); my $fh = IO::Socket::INET-> new(PeerAddr => $ip, PeerPort => $port, Proto => 'tcp', Timeout => 5 ) || die "Can't open $server\n"; print "$server opened, trying socks5\n"; my $sock = new Net::SOCKS(socks_addr => $ip, socks_port => $port, user_id => '', user_password => '', force_nonanonymous => 0, protocol_version => 5) || die "Can't create socket\n"; my $conn = $sock->connect(peer_addr => inet_ntoa(inet_aton($page->host +())), peer_port => $page->port() ) || die "Can't connect to socks5 server\n"; #how to define timeout here ^^^ print "con. status:",Net::SOCKS::status_message($sock->param('status_n +um')),"\n"; $conn->autoflush(1); print "downloading...\n"; print $conn "GET " . $page->path() . " HTTP/1.1\n"; print $conn "Host: " . $page->host() . "\n"; print $conn "Connection: close\n\n"; while (<$conn>) { print } $sock->close(); __END__

2004-12-08 Janitored by Arunbear - added readmore tags, as per Monastery guidelines


In reply to SOCKS5 timeout by 2ge

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.