Re: TCP/IP Sockets with GNAT.Sockets
- From: Dave Thompson <david.thompson1@xxxxxxxxxxxxxxxx>
- Date: Mon, 09 May 2005 04:03:41 GMT
On 2 May 2005 13:22:41 -0700, "fabio de francesco" <fmdf@xxxxxxxxxx>
wrote:
<snip>
> 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<rant>$ 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
.
- References:
- Re: TCP/IP Sockets with GNAT.Sockets
- From: Adrien Plisson
- Re: TCP/IP Sockets with GNAT.Sockets
- From: fabio de francesco
- Re: TCP/IP Sockets with GNAT.Sockets
- From: Björn
- Re: TCP/IP Sockets with GNAT.Sockets
- From: fabio de francesco
- Re: TCP/IP Sockets with GNAT.Sockets
- Prev by Date: Re: creating database
- Next by Date: Re: creating database
- Previous by thread: Re: TCP/IP Sockets with GNAT.Sockets
- Next by thread: Re: Ada.Text_IO and protected objects (Was: [newbie question] tasks and protected types)
- Index(es):
Relevant Pages
|