comp.lang.ada
 help / color / mirror / Atom feed
From: Nasser
Subject: Re: Ada 95 Sockets example wanted
Date: 1997/08/19
Date: 1997-08-19T00:00:00+00:00	[thread overview]
Message-ID: <5tdvo7$3ff@drn.zippo.com> (raw)
In-Reply-To: dewar.871839829@merv


In article <dewar.871839829@merv>, dewar@merv.cs.nyu.edu says...
>
>Marc asks
>
><<I'd like to see some sample Ada 95 software that deals with the
>basics of Unix socket manipulation:  open, close, read, and write.
>I've never had to get down to the low-level interaction with
>sockets, having been able to use various layering packages on
>top of them.>>
>
>One source of sample code is the code for GLADE, the PCS for Ada
>distribution from ACT/Europe. This PCS uses sockets for communication,
>and of course the sources are available for looking at!
>

One thing I noticed just browsing the GLADE code is that when
a socket-related operation failes, a generic Communication_Error 
exception is raised.

In C, one normally reads the value of the global error number, to tell
specifically what the erorr was on the last call.

this is example from GLADE:

"FD := C_Socket (Af_Inet, Sock_Stream, 0);
      if FD = Failure then
         Free (Sin);
         Free (Check);
         raise Communication_Error;
      end if;"

another example:

"if C_Bind (FD,
            To_Sockaddr_Access (Sin),
            Sin.all'Size / 8) = Failure then
         Free (Sin);
         Free (Check);
         raise Communication_Error;"

My question is then, how would the client know the exact error
number, i.e. the reason why the call failed if one just raises
a generic exception?  or a more general question, can one from
gnat get hold of the errno set by calls into C library such as
the socket examples above? 

thanks,
Nasser




  reply	other threads:[~1997-08-19  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-14  0:00 Ada 95 Sockets example wanted Marc A. Criley
1997-08-17  0:00 ` Robert Dewar
1997-08-19  0:00   ` Nasser [this message]
1997-08-20  0:00     ` Robert Dewar
1997-08-21  0:00     ` Samuel Tardieu
1997-08-18  0:00 ` Corey Minyard
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox