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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f6dc5bfebaf357f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g14g2000cwa.googlegroups.com!not-for-mail From: "fabio de francesco" Newsgroups: comp.lang.ada Subject: Re: "broken pipe" while reading/writing stream-based sockets Date: 20 May 2005 08:01:28 -0700 Organization: http://groups.google.com Message-ID: <1116601288.424625.176760@g14g2000cwa.googlegroups.com> References: <1115766179.505983.40960@f14g2000cwb.googlegroups.com> <87zmuxqz0r.fsf@deneb.enyo.de> NNTP-Posting-Host: 80.181.52.152 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1116601294 2689 127.0.0.1 (20 May 2005 15:01:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 20 May 2005 15:01:34 +0000 (UTC) In-Reply-To: <87zmuxqz0r.fsf@deneb.enyo.de> User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g14g2000cwa.googlegroups.com; posting-host=80.181.52.152; posting-account=Lp02jQ0AAABMd3TAghNf0TM2YBZqD_JE Xref: g2news1.google.com comp.lang.ada:11102 Date: 2005-05-20T08:01:28-07:00 List-Id: Florian Weimer wrote: > * fabio de francesco: > > > 1) Why does this server sometimes crash with "Broken Pipe"? > > This usually indicates that the client closed its end of the > connection while the server was still sending data. Maybe this > happens because your code does not deal with partial reads/writes. > > > 2) It seems that using Input/Output instead of Read/Write never causes > > "Broken Pipe". Why? > > The stream implementation provided by GNAT.Sockets deals with partial > reads and writes. In C I know how to read() in a loop and increment a pointer to a buffer (a C string) while receiving characters until there are no more of them. It is sufficient that read() returns how many characters has already read and some little math involving buffer size. In Ada I don't know how to do it... Can you please give me any suggestions? Thank you in advance. fabio