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,d1533431e7e9d2eb X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Nontrivial examples of C interface with Ada Date: 2000/05/25 Message-ID: #1/1 X-Deja-AN: 627298180 References: <8gjqpo$kjv$1@nnrp1.deja.com> X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 959285012 206.170.2.15 (Thu, 25 May 2000 13:03:32 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Thu, 25 May 2000 13:03:32 PDT Newsgroups: comp.lang.ada Date: 2000-05-25T00:00:00+00:00 List-Id: >any further abstracting of the binding to make it simpler is going to >inevitably loose some of the power of the original. Sure, it will be >easier to use, but you won't be able to do as interface. The escape hatch is to have routines that let you get at the lowest level entities and then make whatever system calls you want. function Get_Handle (Socket : in Root_Socket_Type'Class) return Socket_Handles; -- Returns the Windows handle of the socket. procedure Get_Socket_From_Handle (Socket : in out Socket_Type; Handle : in Socket_Handles); -- Handle should be the Windows handle of an open, connected, -- blocking, or non-blocking but with no interrupts allowed, -- stream socket. -- Socket should be a closed CLAW Socket_Type'Class. -- On return, Socket will be open and have Handle as its -- Windows handle. Of course it's also then up to the power user not to trip himself up by his mixing of high and low level calls. >But then how do I set my sockets to non-blocking? That's just a question of how thorough is the coverage of the thick binding. A lot can be done with a Text_IO style interface to blocking sockets, with asynchrony being provided by suitable Ada tasking. In fact, Windows CE does not offer non-blocking sockets, so they expect you to live happily with task switching instead of non-blocking sockets. For Windows versions that do offer non-blocking sockets, Claw includes: type Async_Socket_Type is abstract new Socket_Type with private; -- A concrete non-blocking socket type must be derived from this -- and overriding When_xxx routines supplied. which supplies the blocking socket routines plus primitives procedure When_Connect(Socket : in out Async_Socket_Type); -- Called when the socket becomes connected on an Open call. procedure When_Readable(Socket : in out Async_Socket_Type) is abstract; -- Called when "data is available to read" goes from False to True and so forth.