"global" TCP_NODELAY?

Robert Watson rwatson at FreeBSD.org
Mon Oct 12 18:15:46 UTC 2009

On Mon, 12 Oct 2009, Ivan Voras wrote:

> 2009/10/12 Alfred Perlstein <alfred at freebsd.org>:
>> * Ivan Voras <ivoras at freebsd.org> [091012 04:29] wrote:
>>> I'm trying to work around some extreme brain damageness in PHP (yes, it 
>>> sucks) which doesn't have a way to set TCP_NODELAY on stream sockets so 
>>> I'm wondering what are my other options? Is there a way to set TCP_NODELAY 
>>> system-wide?
>> Ivan, many people write php extensions, maybe you can do that?
> While writing PHP extensions isn't hard (I've done it before), I'm not yet 
> convinced it's worth the effort in this case - I don't know if TCP_NODELAY 
> will help at all. I'll think about it if time permits.

Create a libc wrapper that calls setsockopt(2) whenever socket(2) is called to 
create a TCP socket in php, and inject it using LD_PRELOAD.  This is a similar 
trick to what things like socks proxy library wrappers use, is easy to hack 
together, and avoids having to modify the kernel.  When it doesn't work, move 
on, and if it does, change php :-).

Robert N M Watson
Computer Laboratory
University of Cambridge

More information about the freebsd-hackers mailing list