OK since nobody helped me (sniff, sniff) I had to figure it out myself.
Here is the problem code in the fragment:
$sockaddr = 'S n a4 x8';
replacing it with
$sockaddr = 'x C n a4 x8';
fixed the problem. The template for the pack command was wrong.
Th first two bytes are length (0) and family, both of which are unsigned
char, so 'x C' (or 'n') handles those.
I got this from a similar socket problem posting dug out of
a mailing list posting from 2003.
Perhaps a better way to fix this would be to rewrite it to
do something like:
use Socket;
$that = sockaddr_in($port,inet_aton($newshost));
($newshost is the FQDN of the new host, $thataddr is the IP# of the news
host)
but as I said before, I don't want to rewrite everything.
Ted
On 2/23/2011 8:24 PM, Ted Mittelstaedt wrote:
On 2/23/2011 7:18 PM, Jim Gibson wrote:
At 6:16 PM -0800 2/23/11, Ted Mittelstaedt wrote:
Hi All,
I'm running into a problem with a pretty old freeware perl script called
"readnews" it is in an archive named "readnews-1.85.tar.gz" that is
available here:
http://web.archive.org/web/20080616183736/http://www.scn.org/~bb615/scripts/readnews-1.85.tar.gz
[program fragment snipped]
Everytime I run it I get the immediate error
"Can't connect to XXXX tcp/ip port 119. Error: "
(I removed the name of the actual server system)
Can you connect via telnet?
telnet XXXX 119
Can you ping the server?
ping XXXX
Those will tell you if it is a connectivity problem.
Yes, I can, that works just fine.
I've tried this on several FreeBSD systems and get the same problem
on all of them.
If it was a firewall thing I would expect the code to hang
then fail, but this just exits immediately, like it can't
create the socket.
It can create the socket, but the socket cannot connect to the server
socket.
I know the code is a decade old and probably isn't the
recommended way of doing things nowadays but we want to
upgrade the server and this is what is keeping me from
doing it, and I don't want to really tear into the thing
and use something else.
Any suggestions?
Well I know that it is not what you want to hear, but it is probably
time to rewrite the program using a module that has already been written
and done all of the hard work for you. See the Net::NNTP module on CPAN
or search <http://search.cpan.org> for NNTP for alternatives.
Think of this as a chance to educate. If you were teaching a math
class in elementary school and a child asked how to add 2 + 2 would
you tell them to get a calculator? The NNTP protocol is very simple and
this only uses a few of it's commands.
The code works on older FreeBSD, and on a modern Ubuntu system running
the same version of Perl as on the newer FreeBSD. I have to thus
assume the problem isn't the code, the problem is something inherent
in how Perl is implemented on FreeBSD 8.X. I just don't know what it is.
Ted
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/