From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,INVALID_MSGID, TO_MALFORMED autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c8b574b34e9605de X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: Ada 95 Sockets example wanted Date: 1997/08/21 Message-ID: #1/1 X-Deja-AN: 268544542 Sender: tardieu@esmeralda.enst.fr References: <33F35E0C.6800@vfb23.mds.lmco.com> <5tdvo7$3ff@drn.zippo.com> Mail-Copies-To: sam@ada.eu.org To: Nasser Organization: TELECOM Paris Newsgroups: comp.lang.ada Date: 1997-08-21T00:00:00+00:00 List-Id: >>>>> "Nasser" == Nasser writes: Nasser> One thing I noticed just browsing the GLADE code is that when Nasser> a socket-related operation failes, a generic Nasser> Communication_Error exception is raised. Nasser> In C, one normally reads the value of the global error number, Nasser> to tell specifically what the erorr was on the last call. Yup, because there is no interest in getting the exact error when the DSA's semantics tells we have to raise System.RPC.Communication_Error in this case. GLADE's socket packages are not intended for standalone use, but you can freely adapt them (if you don't infringe the modified GPL) to get errno. Nasser> My question is then, how would the client know the exact error Nasser> number, i.e. the reason why the call failed if one just raises Nasser> a generic exception? or a more general question, can one from Nasser> gnat get hold of the errno set by calls into C library such as Nasser> the socket examples above? You can either import "errno" as an external Interfaces.C.int symbol, or use the undocumented (and not guaranteed to be present in later GNAT releases) function "__get_errno" from libgnat.a (you have to import it also, it takes no argument and returns an Interfaces.C.int). The latter has the advantage of being thread-safe. Sam -- Samuel Tardieu -- sam@ada.eu.org