rfc:socket_getaddrinfo
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:socket_getaddrinfo [2016/08/08 15:20] bp1222 created |
rfc:socket_getaddrinfo [2017/09/22 13:28] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2016-08-08 | * Date: 2016-08-08 | ||
* Author: David Walker (dave@mudsite.com) | * Author: David Walker (dave@mudsite.com) | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC targets a reported feature request in [[https:// | + | This RFC targets a reported feature request in [[https:// |
===== Proposal ===== | ===== Proposal ===== | ||
- | The implementation[1] I'm proposing implements 4 new socket_* | + | The implementation[[https:// |
<file php> | <file php> | ||
- | array socket_getaddrinfo(string node[, mixed service, array hints]) | + | socket_addrinfo_lookup(string node[, mixed service, array hints]) |
- | resource | + | socket_addrinfo_connect(resource $addrinfo) : resource |
- | resource socket_addrinfo_bind(sockaddrresource sockaddr) | + | socket_addrinfo_bind(resource $addrinfo) : resource |
- | null | + | socket_addrinfo_explain(resource $addrinfo) : array |
</ | </ | ||
+ | IPv4 Example | ||
<file php> | <file php> | ||
<?php | <?php | ||
- | $addrinfo = socket_getaddrinfo('127.0.0.1', 2000, array(' | + | $addrinfo = socket_addrinfo_lookup('localhost', 2000, array(' |
$sockaddr = reset($addrinfo); | $sockaddr = reset($addrinfo); | ||
if (!$sockaddr) die ("No Valid Socket Types" | if (!$sockaddr) die ("No Valid Socket Types" | ||
$sock = socket_addrinfo_bind($sockaddr); | $sock = socket_addrinfo_bind($sockaddr); | ||
// ^^ $sock is a socket resource that is bound to 127.0.0.1: | // ^^ $sock is a socket resource that is bound to 127.0.0.1: | ||
- | foreach | + | |
- | | + | var_dump(socket_addrinfo_explain($sockaddr)); |
+ | /* Outputs: | ||
+ | array(5) { | ||
+ | [" | ||
+ | int(0) | ||
+ | [" | ||
+ | int(2) | ||
+ | [" | ||
+ | int(1) | ||
+ | [" | ||
+ | int(6) | ||
+ | [" | ||
+ | array(2) { | ||
+ | [" | ||
+ | | ||
+ | [" | ||
+ | string(9) " | ||
+ | } | ||
} | } | ||
+ | */ | ||
</ | </ | ||
+ | IPv6 Example | ||
+ | <file php> | ||
+ | <?php | ||
+ | $addrinfo = socket_addrinfo_lookup(' | ||
+ | $sockaddr = reset($addrinfo); | ||
+ | if (!$sockaddr) die ("No Valid Socket Types" | ||
+ | $sock = socket_addrinfo_bind($sockaddr); | ||
+ | // ^^ $sock is a socket resource that is bound to [::1]:2000 using TCP/IP ready for reading | ||
+ | |||
+ | var_dump(socket_addrinfo_explain($sockaddr)); | ||
+ | /* Outputs: | ||
+ | array(5) { | ||
+ | [" | ||
+ | int(0) | ||
+ | [" | ||
+ | int(10) | ||
+ | [" | ||
+ | int(1) | ||
+ | [" | ||
+ | int(6) | ||
+ | [" | ||
+ | array(2) { | ||
+ | [" | ||
+ | int(2000) | ||
+ | [" | ||
+ | string(3) ":: | ||
+ | } | ||
+ | } | ||
+ | */ | ||
+ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | New functionality; | + | New functionality; |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 51: | Line 100: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Vote to implement the new functions, would require a 2/3 majority. | + | Vote to implement the new functionality, would require a 2/3 majority. |
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | Vote Start: 2016-08-24 15:23 UTC | ||
+ | |||
+ | Vote End: | ||
===== Implementation ===== | ===== Implementation ===== | ||
+ | |||
+ | - merged into master (i.e. pre 7.2) | ||
+ | - https:// | ||
+ | - https:// | ||
+ | - a link to the PHP manual entry for the feature | ||
===== References ===== | ===== References ===== | ||
- | [1] - [[https:// | + | * [1] - [[https:// |
rfc/socket_getaddrinfo.1470669623.txt.gz · Last modified: 2017/09/22 13:28 (external edit)