php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51879 Add the ability to set the TCP_NODELAY flag for socket streams
Submitted: 2010-05-21 15:56 UTC Modified: 2016-04-29 12:03 UTC
Votes:9
Avg. Score:4.3 ± 1.2
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:3 (37.5%)
From: suppakilla at gmail dot com Assigned: johannes (profile)
Status: Closed Package: Streams related
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: suppakilla at gmail dot com
New email:
PHP Version: OS:

 

 [2010-05-21 15:56 UTC] suppakilla at gmail dot com
Description:
------------
In relation to http://bugs.php.net/bug.php?id=46360 I think it would be useful 
to have the ability to set the TCP_NODELAY flag on socket streams. The arguments 
for this feature request are basically the same as of #6360, and it would 
greatly help with performances under certain circumstances when dealing with 
chatty network protocols.

The following snippet is an example of how the resulting code might look like in 
a PHP script:

$opts = array(
    'socket' => array(
        'tcp_nodelay' => false,
    ),
);
$stream = stream_socket_client($uri, $errno, $errstr, $timeout, $flags, $opts);


Cheers,
Daniele Alessandri


Patches

add-tcp-nodelay (last revision 2011-02-17 20:45 UTC by seld@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-24 11:57 UTC] suppakilla at gmail dot com
In relation to http://bugs.php.net/bug.php?id=46360 I think it would be useful 
to have the ability to set the TCP_NODELAY flag on socket streams. The arguments 
for this feature request are basically the same as of #6360, and it would 
greatly help with performances under certain circumstances when dealing with 
chatty network protocols.

The following snippet is an example of how the resulting code might look like in 
a PHP script:

$opts = array(
    'socket' => array(
        'tcp_nodelay' => false,
    ),
);
$ctx = stream_context_create($opts);
$stream = stream_socket_client($uri, $errno, $errstr, $timeout, $flags, $ctx);


Cheers,
Daniele Alessandri
 [2011-02-17 19:44 UTC] seld@php.net
The following patch has been added/updated:

Patch Name: add-tcp-nodelay
Revision:   1297968256
URL:        http://bugs.php.net/patch-display.php?bug=51879&patch=add-tcp-nodelay&revision=1297968256
 [2011-02-17 19:45 UTC] seld@php.net
So.. I attached a patch, but I have not tested it (can't compile on this machine) and it's also the first time I touch PHP's sources, so given my little C experience it may very well be incorrect. But I wanted to show goodwill. Hopefully someone picks this up and implements this small feature.
 [2011-02-17 20:08 UTC] seld@php.net
The following patch has been added/updated:

Patch Name: add-tcp-nodelay
Revision:   1297969705
URL:        http://bugs.php.net/patch-display.php?bug=51879&patch=add-tcp-nodelay&revision=1297969705
 [2011-02-17 20:11 UTC] seld@php.net
-Assigned To: +Assigned To: johannes
 [2011-02-17 20:11 UTC] seld@php.net
So the attached patch should be good now, as you (johannes) said TCP_NODELAY is used without ifdef [1] already so it should be fine to use it as is.

Now if I could have php-src karma to commit it myself it'd make my day, but I guess that's not good enough :)

[1] http://lxr.php.net/opengrok/xref/PHP_5_3/ext/mysqlnd/mysqlnd_net.c#50
 [2011-02-17 21:27 UTC] seld@php.net
The following patch has been added/updated:

Patch Name: add-tcp-nodelay
Revision:   1297974430
URL:        http://bugs.php.net/patch-display.php?bug=51879&patch=add-tcp-nodelay&revision=1297974430
 [2011-02-17 21:45 UTC] seld@php.net
The following patch has been added/updated:

Patch Name: add-tcp-nodelay
Revision:   1297975503
URL:        http://bugs.php.net/patch-display.php?bug=51879&patch=add-tcp-nodelay&revision=1297975503
 [2013-06-10 21:15 UTC] yunosh@php.net
Bump
 [2016-04-29 12:03 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 [2016-04-29 12:03 UTC] krakjoe@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

The stream context socket option tcp_nodelay => true will set SOL_TCP,NO_DELAY=1 appropriately.

Will be in 7.1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 07:01:28 2024 UTC