관리-도구
편집 파일: gethostbyname-c.yaml
--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: Resolve <tt>host</tt> and return name and address information for it, similarly to gethostbyname(3). <tt>host</tt> can be a domain name or the presentation format of an address. - !ruby/struct:SM::Flow::P body: "Returns an array of information similar to that found in a +struct hostent+:" - !ruby/struct:SM::Flow::VERB body: " - cannonical name: the cannonical name for host in the DNS, or a\n string representing the address\n - aliases: an array of aliases for the canonical name, there may be no aliases\n - address family: usually one of Socket::AF_INET or Socket::AF_INET6\n - address: a string, the binary value of the +struct sockaddr+ for this name, in\n the indicated address family\n - ...: if there are multiple addresses for this host, a series of\n strings/+struct sockaddr+s may follow, not all necessarily in the same\n address family. Note that the fact that they may not be all in the same\n address family is a departure from the behaviour of gethostbyname(3).\n" - !ruby/struct:SM::Flow::P body: "Note: I believe that the fact that the multiple addresses returned are not necessarily in the same address family may be a bug, since if this function actually called gethostbyname(3), ALL the addresses returned in the trailing address list (h_addr_list from struct hostent) would be of the same address family! Examples from my system, OS X 10.3:" - !ruby/struct:SM::Flow::VERB body: " ["localhost", [], 30, "\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\001", "\\177\\000\\000\\001"]\n and\n ["ensemble.local", [], 30, "\\376\\200\\000\\004\\000\\000\\000\\000\\002\\003\\223\\377\\376\\255\\010\\214", "\\300\\250{\\232" ]\n" - !ruby/struct:SM::Flow::P body: "Similar information can be returned by Socket.getaddrinfo if called as:" - !ruby/struct:SM::Flow::VERB body: " Socket.getaddrinfo(<tt>host</tt>, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)\n" - !ruby/struct:SM::Flow::H level: 2 text: Examples - !ruby/struct:SM::Flow::VERB body: " Socket.gethostbyname "example.com"\n => ["example.com", [], 2, "\\300\\000\\"\\246"]\n" - !ruby/struct:SM::Flow::P body: This name has no DNS aliases, and a single IPv4 address. - !ruby/struct:SM::Flow::VERB body: " Socket.gethostbyname "smtp.telus.net"\n => ["smtp.svc.telus.net", ["smtp.telus.net"], 2, "\\307\\271\\334\\371"]\n" - !ruby/struct:SM::Flow::P body: This name is an an alias so the canonical name is returned, as well as the alias and a single IPv4 address. - !ruby/struct:SM::Flow::VERB body: " Socket.gethostbyname "localhost"\n => ["localhost", [], 30, "\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\001", "\\177\\000\\000\\001"]\n" - !ruby/struct:SM::Flow::P body: This machine has no aliases, returns an IPv6 address, and has an additional IPv4 address. - !ruby/struct:SM::Flow::P body: "<tt>host</tt> can also be an IP address in presentation format, in which case a reverse lookup is done on the address:" - !ruby/struct:SM::Flow::VERB body: " Socket.gethostbyname("127.0.0.1")\n => ["localhost", [], 2, "\\177\\000\\000\\001"]\n\n Socket.gethostbyname("192.0.34.166")\n => ["www.example.com", [], 2, "\\300\\000\\"\\246"]\n" - !ruby/struct:SM::Flow::H level: 2 text: See - !ruby/struct:SM::Flow::P body: "See: Socket.getaddrinfo" full_name: TCPSocket::gethostbyname is_singleton: true name: gethostbyname params: " Socket.gethostbyname(host) => hostent\n" visibility: public