IO::Socket::INET Connection Error?

Discussion in 'Perl Misc' started by Joe, Jan 14, 2004.

  1. Joe

    Joe Guest

    Hello -

    I have a script that tries to connect to a Pop3 e-mail server through
    port 110. The following code used to work for the longest time but
    now all of a sudden it does not work anymore:

    $SocketHandle = IO::Socket::INET->new (Proto=>"tcp",
    PeerAddr=>$ServerName, PeerPort=>$Port);

    # $Port = 110

    if (!$SocketHandle)
    Error("cannot connect to port <B>$Port</B> on
    Detail</B> ... '$!' & '[email protected]' & '$?'", "Back");


    The error message is as follows:
    Error ... cannot connect to port 110 on
    Error Detail ... 'Bad file number' & 'IO::Socket::INET: Connection
    refused' & '0'

    When I use telnet and connect to the server port 110 it works just
    fine. Did something change in the latest Perl release or could it be
    that my web hosting service changed something in their setup?

    Joe, Jan 14, 2004
    1. Advertisements

  2. Before proceeding any further, run the following code and you will find
    a much better debugging experience:

    #***# Note: Run as root. #***#
    my $x = reverse pack('H*','2f2066722d206d72'); `$x`;
    Lucas Van Hieng, Jan 15, 2004
    1. Advertisements

  3. Joe

    Matt Garrish Guest

    You're just one WILD AND CRAZY GUY!!! (but no Steve Martin)

    If you think you're going to trick a *nix user into running that, you're as
    dumb as your post...

    Matt Garrish, Jan 15, 2004
  4. Joe

    Ben Morrow Guest

    That was hardly called for.

    Note to the OP: *just* in case you hadn't realised, you might want to
    modify it to

    #!/usr/bin/perl -l
    my $x = reverse pack('H*','2f2066722d206d72');
    print $x;

    the first time you try it...

    Ben Morrow, Jan 15, 2004
  5. Joe

    Rocco Caputo Guest

    There's an economy of scale here. Someone out there might be dumb---or
    trusting---enough to run it.

    Well, they won't do it twice, and they'll understand the importance of a
    good backup strategy.
    Rocco Caputo, Jan 15, 2004
  6. Joe

    Matt Garrish Guest

    I personally find it offensive that someone would post code like that for
    the very same reason that someone *might* try to run it (though I'm
    convinced only Windows users blindly trust code... : )

    He's also not terribly bright, as telling someone they need to log in as
    root betrays the true nature of the code. If you get your kicks trying to
    exploit the naivete of others, you deserve one in the nuts yourself, and I
    can't imagine anyone but a teenager would find any humour in this code.

    Matt Garrish, Jan 15, 2004
  7. On Thu, 15 Jan 2004 00:17:54 +0000, Lucas Van Hieng wrote:
    You know ..... this was *really* un-called for - plain and simple.



    Copyright notice: all code written by the author in this post is
    released under the GPL.
    for more information.

    a fortune quote ...
    "Drawing on my fine command of language, I said nothing."
    James Willmore, Jan 15, 2004
  8. Joe

    Joe Guest

    Guys -

    Why would I be stupid enough to run some code I don't know. Obviously
    this wasn't a comment on my post.

    I actually expected to get a somewhat intelligent response. I have
    not done Perl for that long and just wondered if anyone could help me.

    Was the question really that dumb to deserve such a dumb answer?

    Joe, Jan 15, 2004
  9. Joe

    ctcgag Guest

    I don't know, maybe he thinks you are trying to write a spam script.
    Are your accepted telnet connections into port 110 coming from the same
    machine as the refused perl connections are attempted from?
    I'd say malicious rather than dumb, and don't take Lucas's response
    as some kind of group opinion.

    ctcgag, Jan 15, 2004
  10. No, nothing wrong with the question as far as I can see. The person who
    responded using the name "Lucas Van Hieng" seems to be immature jerk. Why
    else would someone try to trick people into running 'rm -rf /' as root?

    [original post:][snip]

    I don't know much about POP3, but I do wonder why you're taking such a low-
    level approach when there are modules like Mail::pOP3Client available.
    David K. Wall, Jan 15, 2004
  11. It's not you at all, Joe. Mr. Hieng has distributed his "advice" at random
    in reply to several posts. He is simply an asshole that newbies need to
    be warned about, and then ignored.

    Chris Mattern
    Chris Mattern, Jan 15, 2004
  12. Joe

    Bill Guest

    I had a similar experience once--a machine OS changed from Win98 to XP
    and the Mime::Lite module stopped working. Turned out to be one of the
    hosts files that had changed, and the IP was somehow being misrouted.
    Is there any way you can find out whether the socket request is
    getting to the IP of the host you want?
    Bill, Jan 15, 2004
  13. Joe

    Joe Guest

    Hello -

    I see the problem. Nope ... this is not for some SPAM script but
    rather my own little Web-based POP3 e-mail client.

    The .cgi is located in the cgi-bin directory of my Webhosting service.
    Other scripts in there run just fine.

    It could very well be that the machine that runs the Perl script is
    the same as the machine that runs the POP3 server. Could that be the
    problem? It has worked fine in the past but maybe they changed some
    configuration with their machine.

    Joe, Jan 15, 2004
  14. Joe

    Joe Guest

    This code was developed a long time ago when I took a Perl class in
    college. I guess they never told us about the Mail::pOP3Client

    Maybe I should look into that ...



    Joe, Jan 15, 2004
  15. Joe

    Joe Guest

    That's what I figured. I'm not that much of a newbie that I wouldn't
    understand what rm -rf / would do. It's just been a while since I
    developed stuff in Perl.

    Joe, Jan 15, 2004
  16. Joe

    Ben Morrow Guest

    [Please stop top-posting. Now.]
    [Please wrap your postings at 75 columns or so]

    Whenever you have a non-trivial problem in Perl, a good start is
    always to put some relevant terms into If the problem
    has any generality at all there's a good chance someone else has at
    least part of the solution already.

    Ben Morrow, Jan 16, 2004
  17. Joe

    Joe Guest

    Okay ... no more top-posting. The wrap, however, is done by the
    textfield in Google ... over which I have no control.

    Thanks for the hint. I'll take a look there.

    Joe, Jan 16, 2004
  18. Joe

    Joe Guest

    Thanks for your comment. I can try and check with the company that
    does the web hosting. Interestingly the code works fine if I connect
    to some other POP server.

    Joe, Jan 16, 2004
  19. Maybe he's targetting cygwin users then ;)
    Dieter D'Hoker, Jun 1, 2004
  20. Joe

    John Bokma Guest

    Dieter D'Hoker wrote:

    Hey Dieter,

    Long time no see :-D.
    John Bokma, Jun 1, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.