blahblahblah has asked for the wisdom of the Perl Monks concerning the following question:
I'm at a loss as to what could cause this. If it's a firewall or something like that, I think it would block the whole connection. I think a firewall would also block my manual telnet test.
I have two questions, really:
1. Can anyone think of a cause or explanation for this?
2. Do you think that rewriting my code to use IO::Socket might help?
This is a stripped down version of my code to illustrate what it does:
Thanks,my $smtp = '167.206.5.250'; # part 1, connect to server: use Socket; my $proto = (getprotobyname('tcp'))[2]; my $port = (getservbyname('smtp', 'tcp'))[2]; my $smtpaddr = pack('C4',$1,$2,$3,$4) if ( $smtp =~ /^(\d{1,3})\.(\d{1 +,3})\.(\d{1,3})\.(\d{1,3})$/ ); socket(S, AF_INET, SOCK_STREAM, $proto) or die("socket failed: $!"); connect(S, pack('Sna4x8', AF_INET, $port, $smtpaddr)) or die("connect +failed: $!");; # part 2, read first line: local($oldfh) = select(S); $| = 1; select($oldfh); while (my $line = <S>) { print "--> $line\n"; last; }
P.S. I'm using perl 5.8.1 on windows, in case the version/os makes a difference here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hung reading first line of socket
by madizen (Sexton) on Feb 23, 2006 at 05:41 UTC | |
|
Re: hung reading first line of socket
by spiritway (Vicar) on Feb 23, 2006 at 04:10 UTC |