comp.lang.ada
 help / color / mirror / Atom feed
* Ada 95 Sockets example wanted
@ 1997-08-14  0:00 Marc A. Criley
  1997-08-17  0:00 ` Robert Dewar
  1997-08-18  0:00 ` Corey Minyard
  0 siblings, 2 replies; 6+ messages in thread
From: Marc A. Criley @ 1997-08-14  0:00 UTC (permalink / raw)



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.

So now I would like to see some socket manipulation software
written in Ada 95 rather than having to try to modify these various
Ada 83 layering packages to use the Interfaces.C package.

I'll be doing the compilation with GNAT, and working on both HP-UX
and Linux platforms (if that makes any difference), though I'd be
willing to retarget the software written for another Unix box,
assuming there's any significant differences.

Thanks for any assistance.

Marc A. Criley
Lockheed Martin M&DS
marc.criley@lmco.com

(610) 354-7861




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 Sockets example wanted
  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
  1997-08-18  0:00 ` Corey Minyard
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Dewar @ 1997-08-17  0:00 UTC (permalink / raw)



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!





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 Sockets example wanted
  1997-08-14  0:00 Ada 95 Sockets example wanted Marc A. Criley
  1997-08-17  0:00 ` Robert Dewar
@ 1997-08-18  0:00 ` Corey Minyard
  1 sibling, 0 replies; 6+ messages in thread
From: Corey Minyard @ 1997-08-18  0:00 UTC (permalink / raw)



"Marc A. Criley" <crileym@vfb23.mds.lmco.com> writes:

> 
> 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.
> 
> So now I would like to see some socket manipulation software
> written in Ada 95 rather than having to try to modify these various
> Ada 83 layering packages to use the Interfaces.C package.
> 
> I'll be doing the compilation with GNAT, and working on both HP-UX
> and Linux platforms (if that makes any difference), though I'd be
> willing to retarget the software written for another Unix box,
> assuming there's any significant differences.
> 
> Thanks for any assistance.
> 

I have a set of socket bindings on my home page that do a rather thin
binding (http://www.concentric.net/~Minyard).  I also have a program
to page alphanumeric pagers that was written in Ada; it can talk to a
modem sitting on a telnet socket, but it unfortunately does not use
the previously mentioned bindings since it was written before them.
It has a small C file that provides access to select and an open call
and the rest is straight bindings into the Posix calls.

-- 
Corey Minyard               Internet:  minyard@acm.org
  Work: minyard@nortel.ca       UUCP:  minyard@wf-rch.cirr.com




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 Sockets example wanted
  1997-08-17  0:00 ` Robert Dewar
@ 1997-08-19  0:00   ` Nasser
  1997-08-20  0:00     ` Robert Dewar
  1997-08-21  0:00     ` Samuel Tardieu
  0 siblings, 2 replies; 6+ messages in thread
From: Nasser @ 1997-08-19  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 Sockets example wanted
  1997-08-19  0:00   ` Nasser
@ 1997-08-20  0:00     ` Robert Dewar
  1997-08-21  0:00     ` Samuel Tardieu
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1997-08-20  0:00 UTC (permalink / raw)



Nasser says

<<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.
>>


If you want your comment to come to the attention of the people who might
actually pay attention, please send it to the appropriate address. Do not
assume that all the GNAT and GLADE developers read comp.lang.ada regularly
(many of them have long ago decided that it was not worth it, because there
is too much junk here :-)





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 Sockets example wanted
  1997-08-19  0:00   ` Nasser
  1997-08-20  0:00     ` Robert Dewar
@ 1997-08-21  0:00     ` Samuel Tardieu
  1 sibling, 0 replies; 6+ messages in thread
From: Samuel Tardieu @ 1997-08-21  0:00 UTC (permalink / raw)
  To: Nasser


>>>>> "Nasser" == 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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-08-21  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
1997-08-20  0:00     ` Robert Dewar
1997-08-21  0:00     ` Samuel Tardieu
1997-08-18  0:00 ` Corey Minyard

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