Skip to contentSkip to conversation

tcp write returns 0?

DISCUSSION Hua Zhong 2 participants 2 messages Aug 21, 2008

Subsystems (2)
lore
Share & tools
lore

Hua Zhong

author
#0 lore raw

Hi,

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?

Thanks.

Hua

#1 lore raw
Quoted 4 lines · Hua Zhong

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