comp.lang.ada
 help / color / mirror / Atom feed
* Re: Socket programming in Ada
  2000-05-05  0:00 Socket programming in Ada Marc A. Criley
@ 2000-05-05  0:00 ` tmoran
  2000-05-06  0:00 ` David Kristola
  1 sibling, 0 replies; 3+ messages in thread
From: tmoran @ 2000-05-05  0:00 UTC (permalink / raw)


>Are there any bindings and examples of using the select() socket
>monitoring function within an Ada program?
  What platform?  If MS Windows, Claw has a high level socket package,
and the source comes with it.  I made a small version of Claw.Sockets,
capable of running a simple http server, which I understand will be
posted soon (?) for $0 download.




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

* Socket programming in Ada
@ 2000-05-05  0:00 Marc A. Criley
  2000-05-05  0:00 ` tmoran
  2000-05-06  0:00 ` David Kristola
  0 siblings, 2 replies; 3+ messages in thread
From: Marc A. Criley @ 2000-05-05  0:00 UTC (permalink / raw)


Are there any bindings and examples of using the select() socket
monitoring function within an Ada program?

The old PARADISE packages provides such a binding, but that all is
pretty heavyweight and was never updated for Ada 95.  (It still defines
its own C interface types and such.)

The AdaSockets packages are very nice and work well, but select() is not
part of them.

If there's nothing readily available, I'll crank through it myself, but
I'd like to leverage off previous work if possible.  I also have to take
into account that the socket monitoring code would be embedded within a
task, so one might have to worry about signals associated with all this
as well--I've had to worry about that in the past when porting PARADISE
from one platform to another.

Marc A. Criley




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

* Re: Socket programming in Ada
  2000-05-05  0:00 Socket programming in Ada Marc A. Criley
  2000-05-05  0:00 ` tmoran
@ 2000-05-06  0:00 ` David Kristola
  1 sibling, 0 replies; 3+ messages in thread
From: David Kristola @ 2000-05-06  0:00 UTC (permalink / raw)


On Fri, 5 May 2000 5:40:08 -0700, Marc A. Criley wrote
(in message <3912C128.1CB6E348@lmco.com>):

> Are there any bindings and examples of using the select() socket monitoring 
> function within an Ada program?

I've seen Select used in some C code, and i was not impressed.
Select seems to want to do everything at one time for an unknown
number of sockets.  Then you get into problems with the FD_SET
(and family) C macros.

> The AdaSockets packages are very nice and work well, but select() is not 
> part of them.

I have a non-blocking extension to AdaSockets that uses
Sockets.Thin.C_Recvfrom to status a single socket.  It has been
working well.  If you are interested in seeing the code, drop
me an email (see below, the return address in the news header
is invalid because of spam).  I'll eventually make the code
available to all, i'm just not sure where to put it.

> If there's nothing readily available, I'll crank through it myself, but I'd 
> like to leverage off previous work if possible.  I also have to take into 
> account that the socket monitoring code would be embedded within a task, so 
> one might have to worry about signals associated with all this as well--I've 
> had to worry about that in the past when porting PARADISE from one platform 
> to another.

Even using Sockets.Thin.C_Recvfrom to check the status of
connections, i've had them disconnected on me between a status
check and when i tried to write to them.  This causes a broken
pipe signal.  The below GNAT code is from a recent project of
mine.  I hope this helps.

-----------------------------------------------------------------------------
-- Copyright(C) 2000 David Kristola
-- I release this trivial file to the Public Domain
-----------------------------------------------------------------------------

package Signals is
   procedure Attach; -- Attach broken pipe handler.
end Signals;

-----------------------------------------------------------------------------
-- Copyright(C) 2000 David Kristola
-- I release this trivial file to the Public Domain
-----------------------------------------------------------------------------

with System.OS_Interface;
with System.Interrupts;

package body Signals is

   protected Handler is
      procedure Broken_Pipe;
      pragma Interrupt_Handler(Broken_Pipe);
   end Handler;

   protected body Handler is
      procedure Broken_Pipe is
      begin
         null; -- ignore it.
      end Broken_Pipe;
   end Handler;

   procedure Attach is
   begin
      System.Interrupts.Attach_Handler
        (New_Handler => Handler.Broken_Pipe'ACCESS,
         Interrupt   => System.OS_Interface.SIGPIPE);
   end Attach;

end Signals;


--djk, keeper of arcane lore & trivial fluff
email: David95037, at the one and only AOL dat com.
work: the only "Kristola, David (UNKNOWN)" in the lmco company email
address book.






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

end of thread, other threads:[~2000-05-06  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-05  0:00 Socket programming in Ada Marc A. Criley
2000-05-05  0:00 ` tmoran
2000-05-06  0:00 ` David Kristola

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