"global" TCP_NODELAY?

Ivan Voras ivoras at freebsd.org
Mon Oct 12 12:09:37 UTC 2009


Sergey Smitienko wrote:
> Ivan Voras пишет:
>> 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?
> What's wrong with:
> 
> <?php
> $socket = socket_create_listen(1223);
> socket_set_option($socket, SOL_SOCKET, TCP_NODELAY, 1);
> var_dump(socket_get_option($socket, SOL_SOCKET, TCP_NODELAY));
> ?>

These "socket objects" are completely different from fsockopen() "stream 
socket objects", and socket_set_option() doesn't work on those. 
Consequently, you cannot use fgets() and friends to work with sockets 
created with socket_*() and there is apparently no way to wrap sockets 
in streams. It's an already finished application that uses stream-like 
functions (e.g. fgets() and friends) and rewriting it to use raw socket 
recv() and send() would be nasty.



More information about the freebsd-hackers mailing list