Subject: Re: tcp write returns 0?

From: Chris Snook <[email-masked]>
Date: Thu, 21 Aug 2008 16:31:14 -0400

Hua Zhong wrote:
> Under what condition would tcp write return 0?
> 
> Especially since a previous poll() indicates the socket is writable. Could
> this only happen for socket in NONBLOCK mode?

The socket could become unwritable for various reasons between poll() 
returning and the send() call.  This shouldn't happen very often, but if 
the system is under memory pressure and needs to page in data between 
those two calls, that race window can get rather large.  You might want 
to increase your TCP buffer sizes, either per-socket with setsockopt, or 
system-wide with sysctl.

-- Chris