rfc:sendrecvmsg
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | rfc:sendrecvmsg [2013/01/22 17:21] – [Introduction] cataphract | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Request for Comments: How to write RFCs ====== | ||
+ | * Version: 1.0 | ||
+ | * Date: 2013-01-22 | ||
+ | * Author: Gustavo Lopes < | ||
+ | * Status: Under Discussion | ||
+ | * First Published at: http:// | ||
+ | |||
+ | |||
+ | Adds wrappers for '' | ||
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | The module ext/ | ||
+ | |||
+ | ==== Native sendmsg() and recvmsg() functions ==== | ||
+ | |||
+ | The '' | ||
+ | |||
+ | <code lang=" | ||
+ | ssize_t recvmsg(int socket, struct msghdr *message, int flags); | ||
+ | ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags); | ||
+ | |||
+ | |||
+ | struct msghdr { | ||
+ | void | ||
+ | socklen_t | ||
+ | struct iovec *msg_iov; | ||
+ | size_t | ||
+ | void | ||
+ | size_t | ||
+ | int | ||
+ | }; | ||
+ | |||
+ | struct iovec { /* Scatter/ | ||
+ | void *iov_base; | ||
+ | size_t iov_len; | ||
+ | }; | ||
+ | |||
+ | struct cmsghdr { | ||
+ | socklen_t cmsg_len; | ||
+ | int | ||
+ | int | ||
+ | /* followed by unsigned char cmsg_data[]; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | A thorough discussion is not appropriate here. For PHP purposes, what matters is that these functions allow attaching and retrieving some sort of metadata when sending or receiving data, respectively. The type of the metadata units is specified by the pair cmsg_level/ | ||
+ | |||
+ | ===== Rationale ===== | ||
+ | |||
+ | Some functionality is only available by using these functions. It can also save us from polluting '' | ||
+ | |||
+ | ===== Changes to ext/socket ===== | ||
+ | |||
+ | Three new functions are added: | ||
+ | <code lang=" | ||
+ | int socket_recvmsg(resource $socket, /* in/out */ array & | ||
+ | int socket_sendmsg(resource $socket, array $msghdr, int $flags); | ||
+ | int socket_cmsg_space(int $level, int $type); | ||
+ | </ | ||
+ | |||
+ | The last function is analogous to the '' | ||
+ | |||
+ | The arrays match the native structures closely, except prefixes are dropped (for instance, if the native field is named '' | ||
+ | |||
+ | The following message types are supported: | ||
+ | |||
+ | * IPv6 | ||
+ | * IPV6_PKTINFO | ||
+ | * IPV6_HOPLIMIT | ||
+ | * IPV6_TCLASS | ||
+ | * Unix | ||
+ | * SCM_RIGHTS | ||
+ | * SCM_CREDENTIALS/ | ||
+ | |||
+ | The functions '' | ||
+ | |||
+ | ===== Usage examples ===== | ||
+ | |||
+ | See the tests. The branch includes these: | ||
+ | |||
+ | This includes these tests: | ||
+ | - [[https:// | ||
+ | - [[https:// | ||
+ | - [[https:// | ||
+ | - [[https:// | ||
+ | - [[https:// | ||
+ | |||
+ | ===== Patch ===== | ||
+ | |||
+ | The [[https:// | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * 2013-01-22 First draft | ||
+ | |||
+ | |||
rfc/sendrecvmsg.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1