netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rick Jones <rick.jones2@hp.com>
To: Paul Martin <srucnoc@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: TCP partial write
Date: Mon, 15 Jun 2009 10:09:29 -0700	[thread overview]
Message-ID: <4A368049.7080903@hp.com> (raw)
In-Reply-To: <394b5e260906141252g56d4275k185230f724b842ac@mail.gmail.com>

Paul Martin wrote:
> Is it possible that a (non-blocking) TCP write(2) will write a number
> of bytes not multiple of the machine word size? i.e., could a write
> request for 4 bytes return 2?

Yes.

> Also is this an OS-dependent behavior or there is a spec for it? (I
> could find atomic guarantees for pipes and datagram sockets but not
> for TCP)

TCP is a byte-stream. It sends and receives a stream of bytes.  You should/must 
assume that when you do a non-blocking write, it will take any number of the 
bytes you offer from 0 to however many bytes you give it.  And you should/must 
assume that at the other end, your recv/read calls will return with between 0 and 
however many bytes you ask of them, with 0 meaning the remote has said it has 
nothing left to give.

rick jones

  reply	other threads:[~2009-06-15 17:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 19:52 TCP partial write Paul Martin
2009-06-15 17:09 ` Rick Jones [this message]
2009-06-15 17:26   ` Stephen Hemminger
2009-06-15 17:59     ` Rick Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A368049.7080903@hp.com \
    --to=rick.jones2@hp.com \
    --cc=netdev@vger.kernel.org \
    --cc=srucnoc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).