comp.lang.ada
 help / color / mirror / Atom feed
From: David Thompson <dave.thompson2@verizon.net>
Subject: Re: Questions about socket programming
Date: Mon, 12 Jan 2015 15:33:11 -0500
Date: 2015-01-12T15:33:11-05:00	[thread overview]
Message-ID: <3sb8ba1api5dg7ip82n56n34oa0hi5pv5s@4ax.com> (raw)
In-Reply-To: B%Lmw.845696$Ub6.476019@fx20.iad

On Wed, 24 Dec 2014 20:02:42 -0800, Hubert <herrdoktor@fumanchu.com>
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.

  parent reply	other threads:[~2015-01-12 20:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-24 13:43 Questions about socket programming Hubert
2014-12-24 14:22 ` David Botton
2014-12-25  3:59   ` Hubert
2014-12-27  1:21   ` Randy Brukardt
2014-12-27  9:48     ` Dmitry A. Kazakov
2014-12-28  0:44     ` David Botton
2014-12-29 12:52     ` Hubert
2014-12-24 17:02 ` Dmitry A. Kazakov
2014-12-25  4:02   ` Hubert
2014-12-25  4:14     ` Hubert
2015-01-12 20:33     ` David Thompson [this message]
2015-01-13  4:31       ` Hubert
2015-01-13  8:53         ` Dmitry A. Kazakov
2015-01-13 20:31           ` Hubert
2015-01-13 21:17             ` Dmitry A. Kazakov
2015-01-15 13:41 ` Kevin K
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox