diff options
author | Gustavo Lopes <glopes@nebm.ist.utl.pt> | 2012-11-01 20:38:42 +0100 |
---|---|---|
committer | Gustavo Lopes <glopes@nebm.ist.utl.pt> | 2013-02-02 16:38:05 +0100 |
commit | 5e51c851431189677aa80f7a3a863699488678cd (patch) | |
tree | b98fb2a402a9a4cda1fdda646b2653544fcef27c /ext/sockets/php_sockets.h | |
parent | ac47448abb477be99963f0b38fe82ffe78c21a8b (diff) | |
download | php-git-5e51c851431189677aa80f7a3a863699488678cd.tar.gz |
Wrap recvmsg() and sendmsg()
This introduces two new functions:
int socket_recvmsg(resource $socket, array &$msghdr, int $flags)
int socket_sendmsg(resource $socket, array $msghdr, int $flags)
The arrays representing struct msghdr follow the native counterpart
closely: structs are mapped to arrays, fields to array elements whose
key is the name of the field without the prefix (e.g. "name" instead
of "msg_name") and array are mapped to sequential numeric PHP arrays.
Right now the only type of ancillary data supported is fot the
level/type pair IPPROTO_IPV6/IPV6_PKTINFO.
I also refactored out the name resolution functions and made
sockets_strerror() a global function.
Diffstat (limited to 'ext/sockets/php_sockets.h')
-rw-r--r-- | ext/sockets/php_sockets.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 9c5dc5a4aa..9158ca4907 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -85,6 +85,16 @@ ZEND_END_MODULE_GLOBALS(sockets) #define SOCKETS_G(v) (sockets_globals.v) #endif +ZEND_EXTERN_MODULE_GLOBALS(sockets); + +char *sockets_strerror(int error TSRMLS_DC); + +#define PHP_SOCKET_ERROR(socket,msg,errn) \ + socket->error = errn; \ + SOCKETS_G(last_error) = errn; \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, errn, \ + sockets_strerror(errn TSRMLS_CC)) + #else #define phpext_sockets_ptr NULL #endif |