preserving message boundaries

Ed Gould ed at mtxinu.COM
Fri Jun 2 10:39:25 AEST 1989


>There was some discussion earlier about preserving message boundaries,
>and I posted two functions that would do this (by encoding the length
>at the beginning) ...

>I pointed out that I used them on top of TCP (although they work over
>anything).  Someone wrote back that I should just be using send() and
>recv() as this is what they were intended to do.

>So I wrote a test program that [fails]

>recv() does not do atomic reads!  Indeed, the man page says nothing
>about it.  The man page for send() says something very cryptic about
>atomic writes - but even if it is atomic, it is worthless if recv()
>isn't.

send()/recv() can do atomic things *only* if the underlying protocol
supports them.  TCP does not, so there is no way for recv() to know
what was written by send().  If the underlying protocol were UDP,
then send/recv would be atomic.  As they would be, I presume, with
a procotol like SPP/XNS.

>By the way, I am using SunOS 4.0.1.  Should I report this to Sun?  (It
>is not clear from the man pages that this is incorrect behavior.)

This is not a bug, but a condition of the particular protocol (TCP).


-- 
Ed Gould                    mt Xinu, 2560 Ninth St., Berkeley, CA  94710  USA
ed at mtxinu.COM		    +1 415 644 0146

"I'll fight them as a woman, not a lady.  I'll fight them as an engineer."



More information about the Comp.unix.wizards mailing list