rfc:socket_getaddrinfo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:socket_getaddrinfo [2016/08/24 15:24] bp1222rfc:socket_getaddrinfo [2016/09/01 00:02] bp1222
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: Voting+  * Status: Accepted
   * First Published at: http://wiki.php.net/rfc/socket_getaddrinfo   * First Published at: http://wiki.php.net/rfc/socket_getaddrinfo
  
Line 18: Line 18:
 </file> </file>
  
 +IPv4 Example
 <file php> <file php>
 <?php <?php
-$addrinfo = socket_addrinfo_lookup('127.0.0.1', 2000, array('ai_family' => AI_INET, 'ai_socktype' => SOCK_STREAM));+$addrinfo = socket_addrinfo_lookup('localhost', 2000, array('ai_family' => AF_INET, 'ai_socktype' => SOCK_STREAM));
 $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:2000 using TCP/IP ready for reading // ^^ $sock is a socket resource that is bound to 127.0.0.1:2000 using TCP/IP ready for reading
 +
 +var_dump(socket_addrinfo_explain($sockaddr));
 +/* Outputs:
 +array(5) {
 +  ["ai_flags"]=>
 +  int(0)
 +  ["ai_family"]=>
 +  int(2)
 +  ["ai_socktype"]=>
 +  int(1)
 +  ["ai_protocol"]=>
 +  int(6)
 +  ["ai_addr"]=>
 +  array(2) {
 +    ["sin_port"]=>
 +    int(2000)
 +    ["sin_addr"]=>
 +    string(9) "127.0.0.1"
 +  }
 +}
 +*/
 +</file>
 +
 +IPv6 Example
 +<file php>
 +<?php
 +$addrinfo = socket_addrinfo_lookup('localhost', 2000, array('ai_family' => AF_INET6, 'ai_socktype' => SOCK_STREAM));
 +$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) {
 +  ["ai_flags"]=>
 +  int(0)
 +  ["ai_family"]=>
 +  int(10)
 +  ["ai_socktype"]=>
 +  int(1)
 +  ["ai_protocol"]=>
 +  int(6)
 +  ["ai_addr"]=>
 +  array(2) {
 +    ["sin6_port"]=>
 +    int(2000)
 +    ["sin6_addr"]=>
 +    string(3) "::1"
 +  }
 +}
 +*/
 </file> </file>
  
Line 48: Line 101:
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
 Vote to implement the new functionality, would require a 2/3 majority. Vote to implement the new functionality, would require a 2/3 majority.
-<doodle title="Implement socket_getaddrinfo family" auth="bp1222" voteType="single" closed="false">+<doodle title="Implement socket_getaddrinfo family" auth="bp1222" voteType="single" closed="true">
    * Yes    * Yes
    * No    * No
rfc/socket_getaddrinfo.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1