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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: David Thompson Newsgroups: comp.lang.ada Subject: Re: Questions about socket programming Date: Mon, 12 Jan 2015 15:33:11 -0500 Organization: Poor Message-ID: <3sb8ba1api5dg7ip82n56n34oa0hi5pv5s@4ax.com> References: <%pzmw.361295$Mq4.223465@fx25.iad> <1vt5kszrayia0$.18j888endc4qm.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx02.eternal-september.org; posting-host="f94eaf45fc5bd141924fbbc56a4c5daa"; logging-data="16806"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gCarIFL4bYFDFQDHFWstnkac0HdKUfd8=" X-Newsreader: Forte Agent 3.3/32.846 Cancel-Lock: sha1:WZFHgNTirgGPIjxqo27cUnmZOiU= Xref: news.eternal-september.org comp.lang.ada:24552 Date: 2015-01-12T15:33:11-05:00 List-Id: On Wed, 24 Dec 2014 20:02:42 -0800, Hubert wrote: > Thanks, I downloaded the package now and check it out. Can you tell me > if the server package handles long data as well? I understand that the > basic socket send() function sends only as much as fits into the > outgoing buffer and has to be called multiple times for large data > blocks, whereupon the recieve() function must be called multiple times > as well and the original datablock then reassembled by the application. > Does your server handle that scenario and return the original large > datablock or is that left for the application as well? > TCP is a stream protocol. Do not assume that each send on one side corresponds to one recv on the other side; that may work in a test lab with two high-end machines connected by a single uncongested and error-free high-speed LAN. In the real internet data may be split up, combined, or both, usually in ways that depend on fluctuating and unreproducable conditions in places you can't measure. Always design TCP apps so that they either treat data as a stream (which TELNET does) or any needed "records" are self-delimiting -- common methods are terminating chars like CRLF in SMTP/NNTP and FTP commands and HTTP headers, prefix length fields like SSL/TLS, SSH, and modern HTTP data, or closing the TCP connection where there is only one record like old HTTP or basic FTP. If you want record boundaries preserved, use newer (and rarer) SCTP instead. Or use UDP if you need records but can live with fairly small limits (possibly as small as about 512 bytes), and possible loss, duplication and reordering.