Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Are their Documented Default Exit Codes for Certain Modules?

by mmartin (Monk)
on Aug 08, 2013 at 20:46 UTC ( [id://1048642]=perlquestion: print w/replies, xml ) Need Help??

mmartin has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks, got a quick question...

I'm using the Perl Module IO::Socket::INET to open a Socket between two computers. The 'server' PC just sits and waits/listens for a connection and the 'client' initiates the connection and then we send some data to the server.

So in testing stuff with this, i.e. trying to find what possible errors could happen and what things I should handle. I was
wondering if anyone knows of any documentation where this kind of stuff would be written down for this particular Module..?

I've Googled just about every combination of words I can think of for the last 2 or 3 days now and the best site I found was
this one, but it's NOT exactly what I'm looking for... At least I don't think it is?
        http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668%28v=vs.85%29.aspx


I found that link by simply searching for the 2 main errors/warning that I came across which are:
        1. "Connection Refused" with Return_Code=="111"
        2. "No route to host" with Return_Code=="113".

I've verified that I get these Exit codes consistently in specific situations, for example I'll get the "No route to host" if the server PC is
powered-off or if the Ethernet port is disabled or anything along those lines...

I'm calling the script that creates the Socket from within another script and capturing the Return Codes in the calling script, so I was
hoping for some kind of documentation about Exit Codes and what not...


Any know if anything like that exists out there anywhere..?


FYI: If it makes a difference the 'server' side script is running on Windows and the client can run from Linux OR Windows too...


Any thoughts would be much appreciated!

Thanks in Advance,
Matt


Replies are listed 'Best First'.
Re: Are their Documented Default Exit Codes for Certain Modules?
by FloydATC (Deacon) on Aug 09, 2013 at 11:12 UTC
    Generally speaking, some of the most frustrating problems to solve are those where the software tries to hide the actual error messages and explain the problem in "layman terms" so the "user won't get confused". Yes, Microsoft, I'm looking at you. The result is the same every single time; the actual meaning of the original error message is lost and the end user has no way of discerning exactly why he's getting some misleading message about "the PC is powered off" (because it actually isn't) or "the ethernet port is disabled" (no, it's not).

    If at all possible, relay whatever error message the module or operating system returns in verbatim to the user and then optionally ADD hints for well known error messages. Include enough information to actually troubleshoot the problem, such as the IP address and port number. Perhaps the port is blocked by a firewall? Someone typed the IP address wrong in a config file?

    Good:

    No route to host Hint: Is the FOOBAR server running?

    Better:

    Unexpected error connecting to #.#.#.# tcp/#: No route to host Hint: Is the FOOBAR server running?

    Bad:
    Error 111

    Infuriating:
    Server PC down

    -- FloydATC

    Time flies when you don't know what you're doing

Re: Are their Documented Default Exit Codes for Certain Modules?
by thezip (Vicar) on Aug 08, 2013 at 21:40 UTC

    Use the (source) code, Luke...


    What can be asserted without proof can be dismissed without proof. - Christopher Hitchens, 1949-2011
Re: Are their Documented Default Exit Codes for Certain Modules? (errno)
by Anonymous Monk on Aug 09, 2013 at 03:19 UTC
    exit codes for modules don't exist there are exit codes for programs with the universal meaning that zero is no-error, and non-zero is some kind of error ( application-specific )

    and then there is errno, $!, %!, which system calls like open/close/print/socket ....

Re: Are their Documented Default Exit Codes for Certain Modules?
by mmartin (Monk) on Aug 09, 2013 at 14:51 UTC
    Hey guys, I'm just doing a Comment on the original post so I respond to all in one...

    Thanks for the replies!

    thezip,

    Yea, I did check out the source code a few times but I couldn't find any specific error message that
    it prints... So now I'm thinking that it may actually get the errors from the OS if that's possible, but
    I'm not sure...

    Anonymous Monk, thanks for the reply, but I know 0 is no error and non-zero is an error lol... But you did
    help me solve this problem by replying in my other post I talk about below... So thanks!

    FloydATC, thanks for the reply!

    Yea, I TOTALLY agree, that's kinda why I wanted to see what the other possible error messages could be...
    I had only been able so far to come across 2 error messages while debugging/testing my script.

    But basically, my plan from the beginning was to capture the error message and Return Code and display it "AS IS"
    inside a Gtk2 'DialogBox'. But since the script I'm executing is ran in the background using the Perl Module
    Proc::Background I couldn't figure out a way to 'capture' the STDOUT/STDERR in order to display it.
    So my plan was to try and find as many of the Return Codes as I could and use the "Return Codes" inside a switch
    statement and match them up with what their actual error messages would be... So if for example the return code was
    '113' then I would print out "No route to host" which is what I get when I see Return Code == '113'. But I guess that
    would definitely NOT be a very reliable method to use...

    I did have a post open here comment on where I was asking about capturing STDOUT/STDERR from a Process that's running
    in the background, and after I got a reply from "Anonymous Monk" I came to realize something, and I feel REALLY dumb that
    I didn't think of it already... Since the background process that I need to capture any error codes and messages from is a
    script that I wrote, I can just add something in there to print to a log-like file and capture it there instead of printing to
    STDOUT since you'd never see that anyway as the user. So, if for example, the Return Code is NOT equal to 'ZERO' then print the
    error message to a file and read the file in the calling script...


    So I guess that solves BOTH issues with this. I'll just go back to my "background" script and add that stuff to it...


    Thanks again guys for your replies. Very much appreciated!


    Thanks AGAIN,
    Matt

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1048642]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found