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.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48 autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ff1f0403676a2300 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.236.193.73 with SMTP id j49mr11117223yhn.7.1344998913314; Tue, 14 Aug 2012 19:48:33 -0700 (PDT) MIME-Version: 1.0 Path: c6ni115601339qas.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nrc-news.nrc.ca!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Ada Networking (General/Design) Date: Mon, 13 Aug 2012 19:11:30 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: <1gfytw9o9pem2.1xvhednlaotb3$.dlg@40tude.net> NNTP-Posting-Host: Lf0Nl3CcQzx+ocHx9cmuGg.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Tom's custom newsreader Date: 2012-08-13T19:11:30+00:00 List-Id: >>> 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, so they in effect poll for data - or a Please_Quit request. (The non-blocking routines are of course also polling, via the Windows message loop.) There are also ftp, pop3, smtp, http, etc packages built on top.