php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62906 [feature request] add support for CURLOPT_*SOCK* options
Submitted: 2012-08-23 15:02 UTC Modified: 2022-02-13 04:35 UTC
Votes:14
Avg. Score:4.1 ± 0.9
Reproduced:8 of 10 (80.0%)
Same Version:6 (75.0%)
Same OS:5 (62.5%)
From: niki at gorchilov dot com Assigned: laruence (profile)
Status: Assigned Package: cURL related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-08-23 15:02 UTC] niki at gorchilov dot com
Description:
------------
libcurl has 6 callback options that are missing in PHP bindings, but give the user 
great control over the underlying socket:
- CURLOPT_SOCKOPTFUNCTION
- CURLOPT_SOCKOPTDATA
- CURLOPT_OPENSOCKETFUNCTION
- CURLOPT_OPENSOCKETDATA
- CURLOPT_CLOSESOCKETFUNCTION
- CURLOPT_CLOSESOCKETDATA

Without support for these options, developers can't set socket bindings, options 
and marks on connections done via cURL.

That is a great limitation for serious network applications written in PHP. Here's 
one real example:
http://stackoverflow.com/questions/12080550/tproxy-with-libcurl-or-http-streams-
under-php

Full description of these options is available at:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSOCKOPTFUNCTION


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-24 02:32 UTC] laruence@php.net
-Assigned To: +Assigned To: pierrick
 [2012-08-24 02:32 UTC] laruence@php.net
what do you think? maybe expose some new constants?
 [2012-08-24 04:49 UTC] niki at gorchilov dot com
Looked at PHP sources to find how the similar CURLOPT_HEADERFUNCTION has been 
implemented and here's my understanding:
- ext/curl/interface.c is the only file that needs modification
- Seems CURLOPT_SOCKOPTDATA, CURLOPT_OPENSOCKETDATA, CURLOPT_CLOSESOCKETDATA 
cannot be exported to the end user, as PHP will need it internally to pass a 
context to the callback function. No a big deal IMHO.
- remaining three options - CURLOPT_SOCKOPTFUNCTION, CURLOPT_OPENSOCKETFUNCTION, 
CURLOPT_CLOSESOCKETFUNCTION shall be added in PHP_MINIT_FUNCTION, 
_php_curl_set_default_options and _php_curl_setopt.
- all the three callbacks shall be implemented using curl_write_header as a model.

Hope this helps.
 [2012-08-24 13:26 UTC] pierrick@php.net
I'll implement those feature in the master version of curl.
 [2012-08-25 21:49 UTC] pierrick@php.net
A first draft is available here https://github.com/adoy/php-src/commits/curlsock

Laruence if you have some time a code review would be appreciated :)
 [2012-09-07 12:29 UTC] niki at gorchilov dot com
Any update on this?
 [2012-09-07 12:33 UTC] felipe@php.net
-Assigned To: pierrick +Assigned To: laruence
 [2014-08-11 07:30 UTC] mario at xenji dot com
Are there any news about that? It's been a long time and the branch still is around. Could anybody please review it?
 [2015-01-04 13:15 UTC] sjaillet at gmail dot com
Is this still planned or abandoned ?
 [2015-02-28 09:07 UTC] reeze@php.net
ping @laruence ~
 [2016-09-09 13:46 UTC] kermodebear at gmail dot com
Any update on this?
 [2018-03-26 13:33 UTC] cmb@php.net
A pull request might be helpful to push this forward.
 [2022-02-13 04:35 UTC] requinix@php.net
-Block user comment: No +Block user comment: Yes
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC