home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.protocols.tcp-ip      TCP and IP network protocols.      14,669 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 13,772 of 14,669   
   Richard Kettlewell to David Schwartz   
   Re: write(2) returning zero on a TCP soc   
   27 Jul 11 13:29:00   
   
   3f40dea4   
   From: rjk@greenend.org.uk   
      
   David Schwartz  writes:   
      
   > On Jul 27, 1:33 am, Jorgen Grahn  wrote:   
   >> I got this question at work, and was a bit annoyed that I couldn't   
   >> easily find a straight answer in the man pages or in Stevens.   
   >>   
   >> Under what conditions could write(sock, buf, n), with n>0, return zero   
   >> for a TCP socket?  According to POSIX?  In Linux?   
   >>   
   >> The return values I'm comfortable with are:   
   >> n      - all got written   
   >> 1..n-1 - partial write   
   >> -1     - fatal error, EINTR or EWOULDBLOCK   
   >>   
   >> That doesn't seem to leave room for a distinct meaning of 0.   
   >>   
   >> This supposedly happened to the guy who asked me, on Linux. I'm not   
   >> sure if the socket was set blocking or nonblocking.   
   >   
   > Zero means the connection is closed and no bytes were sent.   
      
   That situation yields a return of -1 with errno=EPIPE (and raises   
   SIGPIPE, though that might be ignored); or EBADF if you've closed at   
   this end.   
      
   --   
   http://www.greenend.org.uk/rjk/   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca