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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,af2ede15fd2320cb X-Google-Attributes: gid103376,public From: David Kristola Subject: Re: Socket programming in Ada Date: 2000/05/06 Message-ID: <01HW.B5392FFE0007C0E3078AE41C@news.pacbell.net>#1/1 X-Deja-AN: 619908065 Content-Transfer-Encoding: 7bit References: <3912C128.1CB6E348@lmco.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 957604325 63.194.212.92 (Sat, 06 May 2000 02:12:05 PDT) Organization: heaps of stacks User-Agent: Hogwasher 2.0 (Macintosh) MIME-Version: 1.0 NNTP-Posting-Date: Sat, 06 May 2000 02:12:05 PDT Newsgroups: comp.lang.ada Date: 2000-05-06T00:00:00+00:00 List-Id: 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.