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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ff1f0403676a2300 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.103.197 with SMTP id fy5mr1565024wib.1.1344888197113; Mon, 13 Aug 2012 13:03:17 -0700 (PDT) Path: n2ni114448226win.0!nntp.google.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Networking (General/Design) Date: Mon, 13 Aug 2012 22:03:16 +0200 Organization: cbb software GmbH Message-ID: <19sij6rw9nhaa.164mz6sr816wk.dlg@40tude.net> References: <1gfytw9o9pem2.1xvhednlaotb3$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 9A8bJrx4NhDLcSmbrb6AdA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-08-13T22:03:16+02:00 List-Id: On Mon, 13 Aug 2012 19:11:30 +0000 (UTC), tmoran@acm.org wrote: >>>> If Ada provided higher level socket library with an integrated support of >>>> protected objects and tasks... >>> What do you mean? >> >>The most difficult and unavoidable part about socket programming is >>tasking. We need reader and writer tasks or else socket-select-driven >>co-routines. The reader and writer parts have to communicate each other in >>some intricate way because it is two tasks but one protocol state machine, >>or one task and many state machines in the case of socket select. There is >>the issue of blocking socket I/O non-abortable by Ada means. All this > > The Claw.Sockets package has a simple Socket_Type with > procedure Open(Socket : in out Socket_Type; -- or Server_Type > Domain_Name: in String; -- or Network_Address_Type > Port : in Port_Type; > Timeout : in Duration := 30.0); > and Text_IO style Get/Put for Strings, Input/Output for streams, etc. > It also has a non-blocking Async_Socket_Type with overridable > When_Connect, When_Readable, etc routines, but I find using blocking > sockets with tasks whose structure encodes the state machine is much > simpler. All the blocking socket routines allow a timeout parameter, In an Ada friendly way they should be entry calls, with the semantics of canceling the request when a timed entry call gets timed out. That is when the socket is blocking: select Socket.Receive (Packet); or delay 10.0; -- Failed to read or terminate; -- Yes I know, it is illegal to have terminate + delay end select; Or maybe other way round, they should be "entry points" to which socket I/O could call to. For non-blocking I/O there should be a way to have a pseudo-task ran by the events on the socket, rather than scheduled. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de