comp.lang.ada
 help / color / mirror / Atom feed
From: David Kristola <David95037@See-My.Sig>
Subject: Re: Socket programming in Ada
Date: 2000/05/06
Date: 2000-05-06T00:00:00+00:00	[thread overview]
Message-ID: <01HW.B5392FFE0007C0E3078AE41C@news.pacbell.net> (raw)
In-Reply-To: 3912C128.1CB6E348@lmco.com

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.






      parent reply	other threads:[~2000-05-06  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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