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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7db5fb0599fd4b76 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!wn12feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail From: Dave Thompson Newsgroups: comp.lang.ada Subject: Re: TCP/IP Sockets with GNAT.Sockets Message-ID: References: <1115001752.291144.218410@z14g2000cwz.googlegroups.com> <427618e9$0$7743$ba620e4c@news.skynet.be> <1115045740.838321.306480@g14g2000cwa.googlegroups.com> <1115062753.107263.233720@z14g2000cwz.googlegroups.com> <1115065361.677409.82970@z14g2000cwz.googlegroups.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 09 May 2005 04:03:41 GMT NNTP-Posting-Host: 12.76.19.57 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1115611421 12.76.19.57 (Mon, 09 May 2005 04:03:41 GMT) NNTP-Posting-Date: Mon, 09 May 2005 04:03:41 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:10960 Date: 2005-05-09T04:03:41+00:00 List-Id: On 2 May 2005 13:22:41 -0700, "fabio de francesco" wrote: > TCP is a byte-stream protocol with NO record boundaries. When reading > from a TCP socket in a C program we have always to code the read() in a > loop and terminate only when no more characters are read (function True -- and important: in the typical program-development environment programs are run in isolation, often slow-stepped, on unloaded machines in a secluded subnet, and most if not all TCP/IP stacks in such environments _do_ "accidentally" preserve buffer boundaries, so that programs depending on this "appear" to work, and only when they are deployed to the real-world net of long, heterogenous, overloaded, and varying paths do they fail, and even then "only" occasionally and unpredictably, except that by Murphy's law some occasions will be when your most important user(s)/customer(s)/prospect(s)/boss(es) are doing something particularly important. Er, -11L I$ 9L :L I$$ (Or, can I combine those as 9:L ? I can't recall.) > returns value 0 of type "ssize_t" that could be an Integer in Ada I > suppose). > Socket-for-TCP read() or recv() returns 0 only when the peer has closed or half-closed, i.e., at "end of file". To read less than all of the data on the connection (but more than 1 octet) you must code to read repeatedly (usually in a loop) until you get all of the expected data, usually determined by a known (fixed or prefix) count or a delimiter; or with no expectation until a nonblocking socket returns -1 and sets (the value accessed by) errno to EAGAIN or EWOULDBLOCK or select/poll indicates no data ready for a sufficient time (which most simply can be any time at all). ssize_t will certainly be some integer type. On most machines addresses are the same "word" size as default integers and thus likely Integer; and even if the usable object size is much smaller than the address size and hence nominal address space it is usually convenient to still use the address size for size_t and ssize_t; but neither of these is required or guaranteed. Whatever binding(s) you use should certainly provide a suitable type definition of this for you. - David.Thompson1 at worldnet.att.net