"global" TCP_NODELAY?

View: New views
12 Messages — Rating Filter:   Alert me  

"global" TCP_NODELAY?

by Ivan Voras-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Sergey Smitienko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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));
?>

_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Bernd Walter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 12, 2009 at 01:27:28PM +0200, Ivan Voras 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?

net.inet.tcp.delayed_ack
net.inet.tcp.delacktime

Depending on your application it may be sufficient to just reduce the
time.

--
B.Walter <bernd@...> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Ivan Voras-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bernd Walter wrote:

> On Mon, Oct 12, 2009 at 01:27:28PM +0200, Ivan Voras 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?
>
> net.inet.tcp.delayed_ack
> net.inet.tcp.delacktime
>
> Depending on your application it may be sufficient to just reduce the
> time.

Really? Doesn't TCP_NODELAY (Nagle's algorithm) work on buffers to be
sent rather than on ACKs on received data?

_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Ivan Voras-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Bernd Walter-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 12, 2009 at 01:42:08PM +0200, Ivan Voras wrote:

> Bernd Walter wrote:
> >On Mon, Oct 12, 2009 at 01:27:28PM +0200, Ivan Voras 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?
> >
> >net.inet.tcp.delayed_ack
> >net.inet.tcp.delacktime
> >
> >Depending on your application it may be sufficient to just reduce the
> >time.
>
> Really? Doesn't TCP_NODELAY (Nagle's algorithm) work on buffers to be
> sent rather than on ACKs on received data?

Good point.
TCP_NODELAY disables both to my knowledge.
And setting delacktime to 1 helped me in one buffer case.
But I'm not sure anymore - a non delayed ack might piggypack payload
much sooner of course.

--
B.Walter <bernd@...> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Tom Judge :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ivan Voras wrote:

> 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.
Is this for php java bridge by any chance?  If so I believe we have a
patch floating around so that it can use UNIX sockets rather than INET ones.

TJ
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Ivan Voras-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tom Judge wrote:

> Ivan Voras wrote:
>> 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.
> Is this for php java bridge by any chance?  If so I believe we have a
> patch floating around so that it can use UNIX sockets rather than INET
> ones.

No, something in-house.

_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Alfred Perlstein-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Ivan Voras <ivoras@...> [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?


--
- Alfred Perlstein
.- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250
.- FreeBSD committer
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Ivan Voras-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/12 Alfred Perlstein <alfred@...>:
> * Ivan Voras <ivoras@...> [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.
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Robert Watson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, 12 Oct 2009, Ivan Voras wrote:

> 2009/10/12 Alfred Perlstein <alfred@...>:
>> * Ivan Voras <ivoras@...> [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
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."

Re: "global" TCP_NODELAY?

by Ivan Voras-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/12 Robert Watson <rwatson@...>:

> 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.

This is actually the sanest idea I've yet come across, including
modifying PHP :)
_______________________________________________
freebsd-hackers@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@..."