Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Problem in IO::Socket syntax?

by flocto (Pilgrim)
on Mar 31, 2002 at 00:54 UTC ( [id://155536]=note: print w/replies, xml ) Need Help??


in reply to Problem in IO::Socket syntax?

Well, AFAIK IO::Socket returns undef upon failure, and will have a hard time closing an undefined variable. In this case you should change your code to:
if ($disco) { print "$host FAILED to respond on $service $ports{$service}\n"; } else { close $checkport; }
I couldn't find IO::Socket's return value when failing in it's documentation, but that it calls connect(), and this returns false when failing. I can't imagine that it (IO::Socket) would return a socket even when failing to open one, so my guess is that this is your mistake. I don't use IO::Socket all that often, so I might be wrong here.. Hope this helps ;)

-octo-

Replies are listed 'Best First'.
(tye)Re: Problem in IO::Socket syntax?
by tye (Sage) on Mar 31, 2002 at 06:59 UTC

    And when it fails, please also report why it failed. How to find out why it failed varies by module, but for IO::Socket, I'm pretty sure it is the common $! that you want to report in the error message.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://155536]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-18 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found