Re: read on socket shows EOF... but only when app is running in background

phn_at_icke-reklam.ipsec.nu
Date: 08/19/04


Date: Thu, 19 Aug 2004 13:46:27 +0000 (UTC)

In comp.os.linux.development Ruud Schramp <r.schramp@telecom.dot.tno.dot.nl> wrote:
> Hello All,

> Does anybody know other reasons a TCP Socket will read eof besides being
> closed localy or receiving a FIN packet?

Yes.

The stack might not have all the requested number of bytes available,
giving your read(2) only the amount it has ( the rest is in
transit and will be avalable later)

Always test the number returned from read(), never assume
the chunks written is equals the chunks read.

See p9 and 77 in UNIX network programming volume 1 by R stevens,
isbn 0-13-490012-x

-- 
Peter Håkanson         
        IPSec  Sverige      ( At Gothenburg Riverside )
           Sorry about my e-mail address, but i'm trying to keep spam out,
	   remove "icke-reklam" if you feel for mailing me. Thanx.


Relevant Pages

  • Re: Setting size limit of data while reading or writing from sockets
    ... refuse to receive the data the networking stack has already received ... calling read you would let the socket buffer fill up and therefore not ... I'm saying that the networking stack has the right to refuse to ... No rule prohibits the stack from receiving three application data ...
    (comp.unix.programmer)
  • Re: Graphing Step Response Error
    ... to plot it, I'm receiving this error: ... Input argument "hFig" is undefined. ... What's the full text (including the stack) of the error message? ...
    (comp.soft-sys.matlab)