From: Matteo Nastasi (mop) Date: Thu, 28 Jun 2012 05:34:49 +0000 (+0200) Subject: control socket added to receive socket-related data X-Git-Tag: v0.2.0~1 X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=php-ancillary.git;a=commitdiff_plain;h=14be27b93ea230a1c3dd702ae33e366bb11be728 control socket added to receive socket-related data --- diff --git a/php-ancillary.c b/php-ancillary.c index 115221a..4907812 100644 --- a/php-ancillary.c +++ b/php-ancillary.c @@ -3,6 +3,10 @@ #endif #include "php.h" #include + +#include +#include +#include #define PHP_ANCILLARY_VERSION "1.0" #define PHP_ANCILLARY_EXTNAME "ancillary" @@ -45,7 +49,12 @@ PHP_FUNCTION(ancillary_getstream) { zval *zstream; php_stream *stream; - int fd_in, fd_out; + int fd_in, fd_out[2]; + char *headers; + + if ((headers = calloc(8*1024, 1)) == NULL) { + return; + } if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream)) return; @@ -56,11 +65,25 @@ PHP_FUNCTION(ancillary_getstream) RETURN_FALSE; } - if(ancil_recv_fd(fd_in, &fd_out)) { + if(ancil_recv_fds(fd_in, fd_out, 2) == 0) { RETURN_FALSE; } + { + char bf[2048]; + + sprintf(bf, "zero: [%d] uno: [%d]\n", fd_out[0], fd_out[1]); + write(1, bf, strlen(bf)); + } + { + int fh; + + if ((fh = open("/tmp/out_php-anc.txt", O_WRONLY | O_CREAT | O_APPEND)) > -1) { + // write(fh, headers, 8*1024); + close(fh); + } + } - if ((stream = php_stream_fopen_from_fd(fd_out, "r+b", NULL)) == NULL) { + if ((stream = php_stream_fopen_from_fd(fd_out[0], "r+b", NULL)) == NULL) { RETURN_FALSE; }