mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 05:25:34 +02:00
* ext/socket: AddrInfo is renamed to Addrinfo. [ruby-dev:37876]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b3e665760e
commit
88f04bdd32
13 changed files with 229 additions and 225 deletions
|
@ -736,7 +736,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
*
|
||||
* _dest_sockaddr_ is a destination socket address for connection-less socket.
|
||||
* It should be a sockaddr such as a result of Socket.sockaddr_in.
|
||||
* An AddrInfo object can be used too.
|
||||
* An Addrinfo object can be used too.
|
||||
*
|
||||
* _controls_ is a list of ancillary data.
|
||||
* The element of _controls_ should be Socket::AncillaryData or
|
||||
|
@ -997,7 +997,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
* _mesg_ is a string of the received message.
|
||||
*
|
||||
* _sender_addrinfo_ is a sender socket address for connection-less socket.
|
||||
* It is an AddrInfo object.
|
||||
* It is an Addrinfo object.
|
||||
* For connection-oriented socket such as TCP, sender_addrinfo is platform dependent.
|
||||
*
|
||||
* _rflags_ is a flags on the received message which is bitwise OR of MSG_* constants such as Socket::MSG_TRUNC.
|
||||
|
|
|
@ -359,12 +359,12 @@ bsock_getpeername(VALUE sock)
|
|||
* call-seq:
|
||||
* bsock.local_address => addrinfo
|
||||
*
|
||||
* Returns an AddrInfo object for local address obtained by getsockname.
|
||||
* Returns an Addrinfo object for local address obtained by getsockname.
|
||||
*
|
||||
* Note that addrinfo.protocol is filled by 0.
|
||||
*
|
||||
* TCPServer.open("127.0.0.1", 1512) {|serv|
|
||||
* p serv.local_address #=> #<AddrInfo: 127.0.0.1:1512 TCP>
|
||||
* p serv.local_address #=> #<Addrinfo: 127.0.0.1:1512 TCP>
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
@ -385,14 +385,14 @@ bsock_local_address(VALUE sock)
|
|||
* call-seq:
|
||||
* bsock.remote_address => addrinfo
|
||||
*
|
||||
* Returns an AddrInfo object for remote address obtained by getpeername.
|
||||
* Returns an Addrinfo object for remote address obtained by getpeername.
|
||||
*
|
||||
* Note that addrinfo.protocol is filled by 0.
|
||||
*
|
||||
* TCPServer.open("127.0.0.1", 1728) {|serv|
|
||||
* c = TCPSocket.new("127.0.0.1", 1728)
|
||||
* s = serv.accept
|
||||
* p s.remote_address #=> #<AddrInfo: 127.0.0.1:36504 TCP>
|
||||
* p s.remote_address #=> #<Addrinfo: 127.0.0.1:36504 TCP>
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ VALUE rb_cUNIXSocket;
|
|||
VALUE rb_cUNIXServer;
|
||||
#endif
|
||||
VALUE rb_cSocket;
|
||||
VALUE rb_cAddrInfo;
|
||||
VALUE rb_cAddrinfo;
|
||||
|
||||
VALUE rb_eSocket;
|
||||
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
require 'socket.so'
|
||||
|
||||
class AddrInfo
|
||||
# creates an AddrInfo object from the arguments.
|
||||
class Addrinfo
|
||||
# creates an Addrinfo object from the arguments.
|
||||
#
|
||||
# The arguments are interpreted as similar to self.
|
||||
#
|
||||
# AddrInfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80)
|
||||
# #=> #<AddrInfo: 221.186.184.68:80 TCP (www.ruby-lang.org:80)>
|
||||
# Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80)
|
||||
# #=> #<Addrinfo: 221.186.184.68:80 TCP (www.ruby-lang.org:80)>
|
||||
#
|
||||
# AddrInfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2")
|
||||
# #=> #<AddrInfo: /tmp/sock2 SOCK_STREAM>
|
||||
# Addrinfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2")
|
||||
# #=> #<Addrinfo: /tmp/sock2 SOCK_STREAM>
|
||||
#
|
||||
def family_addrinfo(*args)
|
||||
if args.empty?
|
||||
raise ArgumentError, "no address specified"
|
||||
elsif AddrInfo === args.first
|
||||
elsif Addrinfo === args.first
|
||||
raise ArgumentError, "too man argument" if args.length != 1
|
||||
elsif self.ip?
|
||||
raise ArgumentError, "IP address needs host and port but #{args.length} arguments given" if args.length != 2
|
||||
host, port = args
|
||||
AddrInfo.getaddrinfo(host, port, self.pfamily, self.socktype, self.protocol)[0]
|
||||
Addrinfo.getaddrinfo(host, port, self.pfamily, self.socktype, self.protocol)[0]
|
||||
elsif self.unix?
|
||||
raise ArgumentError, "UNIX socket needs single path argument but #{args.length} arguments given" if args.length != 1
|
||||
path, = args
|
||||
AddrInfo.unix(path)
|
||||
Addrinfo.unix(path)
|
||||
else
|
||||
raise ArgumentError, "unexpected family"
|
||||
end
|
||||
|
@ -57,13 +57,13 @@ class AddrInfo
|
|||
# If a block is given, it is called with the socket and the value of the block is returned.
|
||||
# The socket is returned otherwise.
|
||||
#
|
||||
# AddrInfo.tcp("www.ruby-lang.org", 80).connect_from("0.0.0.0", 4649) {|s|
|
||||
# Addrinfo.tcp("www.ruby-lang.org", 80).connect_from("0.0.0.0", 4649) {|s|
|
||||
# s.print "GET / HTTP/1.0\r\n\r\n"
|
||||
# p s.read
|
||||
# }
|
||||
#
|
||||
# # AddrInfo object can be taken for the argument.
|
||||
# AddrInfo.tcp("www.ruby-lang.org", 80).connect_from(AddrInfo.tcp("0.0.0.0", 4649)) {|s|
|
||||
# # Addrinfo object can be taken for the argument.
|
||||
# Addrinfo.tcp("www.ruby-lang.org", 80).connect_from(Addrinfo.tcp("0.0.0.0", 4649)) {|s|
|
||||
# s.print "GET / HTTP/1.0\r\n\r\n"
|
||||
# p s.read
|
||||
# }
|
||||
|
@ -77,7 +77,7 @@ class AddrInfo
|
|||
# If a block is given, it is called with the socket and the value of the block is returned.
|
||||
# The socket is returned otherwise.
|
||||
#
|
||||
# AddrInfo.tcp("www.ruby-lang.org", 80).connect {|s|
|
||||
# Addrinfo.tcp("www.ruby-lang.org", 80).connect {|s|
|
||||
# s.print "GET / HTTP/1.0\r\n\r\n"
|
||||
# p s.read
|
||||
# }
|
||||
|
@ -91,7 +91,7 @@ class AddrInfo
|
|||
# If a block is given, it is called with the socket and the value of the block is returned.
|
||||
# The socket is returned otherwise.
|
||||
#
|
||||
# AddrInfo.tcp("0.0.0.0", 4649).connect_to("www.ruby-lang.org", 80) {|s|
|
||||
# Addrinfo.tcp("0.0.0.0", 4649).connect_to("www.ruby-lang.org", 80) {|s|
|
||||
# s.print "GET / HTTP/1.0\r\n\r\n"
|
||||
# p s.read
|
||||
# }
|
||||
|
@ -106,7 +106,7 @@ class AddrInfo
|
|||
# If a block is given, it is called with the socket and the value of the block is returned.
|
||||
# The socket is returned otherwise.
|
||||
#
|
||||
# AddrInfo.udp("0.0.0.0", 9981).bind {|s|
|
||||
# Addrinfo.udp("0.0.0.0", 9981).bind {|s|
|
||||
# s.local_address.connect {|s| s.send "hello", 0 }
|
||||
# p s.recv(10) #=> "hello"
|
||||
# }
|
||||
|
@ -145,16 +145,16 @@ class AddrInfo
|
|||
end
|
||||
end
|
||||
|
||||
# iterates over the list of AddrInfo objects obtained by AddrInfo.getaddrinfo.
|
||||
# iterates over the list of Addrinfo objects obtained by Addrinfo.getaddrinfo.
|
||||
#
|
||||
# AddrInfo.foreach(nil, 80) {|x| p x }
|
||||
# #=> #<AddrInfo: 127.0.0.1:80 TCP (:80)>
|
||||
# # #<AddrInfo: 127.0.0.1:80 UDP (:80)>
|
||||
# # #<AddrInfo: [::1]:80 TCP (:80)>
|
||||
# # #<AddrInfo: [::1]:80 UDP (:80)>
|
||||
# Addrinfo.foreach(nil, 80) {|x| p x }
|
||||
# #=> #<Addrinfo: 127.0.0.1:80 TCP (:80)>
|
||||
# # #<Addrinfo: 127.0.0.1:80 UDP (:80)>
|
||||
# # #<Addrinfo: [::1]:80 TCP (:80)>
|
||||
# # #<Addrinfo: [::1]:80 UDP (:80)>
|
||||
#
|
||||
def self.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, &block)
|
||||
AddrInfo.getaddrinfo(nodename, service, family, socktype, protocol, flags).each(&block)
|
||||
Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags).each(&block)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -189,10 +189,10 @@ class Socket
|
|||
|
||||
local_addr_list = nil
|
||||
if local_host != nil || local_port != nil
|
||||
local_addr_list = AddrInfo.getaddrinfo(local_host, local_port, nil, :STREAM, nil)
|
||||
local_addr_list = Addrinfo.getaddrinfo(local_host, local_port, nil, :STREAM, nil)
|
||||
end
|
||||
|
||||
AddrInfo.foreach(host, port, nil, :STREAM) {|ai|
|
||||
Addrinfo.foreach(host, port, nil, :STREAM) {|ai|
|
||||
if local_addr_list
|
||||
local_addr = local_addr_list.find {|local_ai| local_ai.afamily == ai.afamily }
|
||||
next if !local_addr
|
||||
|
@ -227,7 +227,7 @@ class Socket
|
|||
end
|
||||
|
||||
def self.tcp_server_sockets_port0(host)
|
||||
ai_list = AddrInfo.getaddrinfo(host, 0, nil, :STREAM, nil, Socket::AI_PASSIVE)
|
||||
ai_list = Addrinfo.getaddrinfo(host, 0, nil, :STREAM, nil, Socket::AI_PASSIVE)
|
||||
begin
|
||||
sockets = []
|
||||
port = nil
|
||||
|
@ -244,7 +244,7 @@ class Socket
|
|||
s.bind(ai)
|
||||
port = s.local_address.ip_port
|
||||
else
|
||||
s.bind(AddrInfo.tcp(ai.ip_address, port))
|
||||
s.bind(Addrinfo.tcp(ai.ip_address, port))
|
||||
end
|
||||
s.listen(5)
|
||||
}
|
||||
|
@ -280,21 +280,21 @@ class Socket
|
|||
#
|
||||
# # The sockets contains IPv6 and IPv4 sockets.
|
||||
# sockets.each {|s| p s.local_address }
|
||||
# #=> #<AddrInfo: [::]:1296 TCP>
|
||||
# # #<AddrInfo: 0.0.0.0:1296 TCP>
|
||||
# #=> #<Addrinfo: [::]:1296 TCP>
|
||||
# # #<Addrinfo: 0.0.0.0:1296 TCP>
|
||||
#
|
||||
# # IPv6 and IPv4 socket has same port number, 53114, even if it is choosen dynamically.
|
||||
# sockets = Socket.tcp_server_sockets(0)
|
||||
# sockets.each {|s| p s.local_address }
|
||||
# #=> #<AddrInfo: [::]:53114 TCP>
|
||||
# # #<AddrInfo: 0.0.0.0:53114 TCP>
|
||||
# #=> #<Addrinfo: [::]:53114 TCP>
|
||||
# # #<Addrinfo: 0.0.0.0:53114 TCP>
|
||||
#
|
||||
def self.tcp_server_sockets(host=nil, port)
|
||||
return tcp_server_sockets_port0(host) if port == 0
|
||||
begin
|
||||
last_error = nil
|
||||
sockets = []
|
||||
AddrInfo.foreach(host, port, nil, :STREAM, nil, Socket::AI_PASSIVE) {|ai|
|
||||
Addrinfo.foreach(host, port, nil, :STREAM, nil, Socket::AI_PASSIVE) {|ai|
|
||||
begin
|
||||
s = ai.listen
|
||||
rescue SystemCallError
|
||||
|
@ -344,7 +344,7 @@ class Socket
|
|||
end
|
||||
|
||||
# creates a TCP server on _port_ and calls the block for each connection accepted.
|
||||
# The block is called with a socket and a client_address as an AddrInfo object.
|
||||
# The block is called with a socket and a client_address as an Addrinfo object.
|
||||
#
|
||||
# If _host_ is specified, it is used with _port_ to determine the server addresses.
|
||||
#
|
||||
|
@ -355,8 +355,8 @@ class Socket
|
|||
# It means that the next connection is not accepted until the block returns.
|
||||
# So concurrent mechanism, thread for example, should be used to service multiple clients at a time.
|
||||
#
|
||||
# Note that AddrInfo.getaddrinfo is used to determine the server socket addresses.
|
||||
# When AddrInfo.getaddrinfo returns two or more addresses,
|
||||
# Note that Addrinfo.getaddrinfo is used to determine the server socket addresses.
|
||||
# When Addrinfo.getaddrinfo returns two or more addresses,
|
||||
# IPv4 and IPv6 address for example,
|
||||
# all of them are used.
|
||||
# Socket.tcp_server_loop succeeds if one socket can be used at least.
|
||||
|
@ -411,7 +411,7 @@ class Socket
|
|||
# }
|
||||
#
|
||||
def self.unix(path) # :yield: socket
|
||||
addr = AddrInfo.unix(path)
|
||||
addr = Addrinfo.unix(path)
|
||||
sock = addr.connect
|
||||
if block_given?
|
||||
begin
|
||||
|
@ -430,7 +430,7 @@ class Socket
|
|||
#
|
||||
# socket = Socket.unix_server_socket("/tmp/s")
|
||||
# p socket #=> #<Socket:fd 3>
|
||||
# p socket.local_address #=> #<AddrInfo: /tmp/s SOCK_STREAM>
|
||||
# p socket.local_address #=> #<Addrinfo: /tmp/s SOCK_STREAM>
|
||||
#
|
||||
def self.unix_server_socket(path)
|
||||
begin
|
||||
|
@ -440,7 +440,7 @@ class Socket
|
|||
if st && st.socket? && st.owned?
|
||||
File.unlink path
|
||||
end
|
||||
AddrInfo.unix(path).listen
|
||||
Addrinfo.unix(path).listen
|
||||
end
|
||||
|
||||
# creates a UNIX socket server on _path_.
|
||||
|
|
|
@ -505,7 +505,7 @@ check_addrinfo(VALUE self)
|
|||
{
|
||||
Check_Type(self, RUBY_T_DATA);
|
||||
if (!IS_ADDRINFO(self)) {
|
||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected AddrInfo)",
|
||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected Addrinfo)",
|
||||
rb_class2name(CLASS_OF(self)));
|
||||
}
|
||||
return DATA_PTR(self);
|
||||
|
@ -558,7 +558,7 @@ addrinfo_new(struct sockaddr *addr, socklen_t len,
|
|||
VALUE a;
|
||||
rb_addrinfo_t *rai;
|
||||
|
||||
a = addrinfo_s_allocate(rb_cAddrInfo);
|
||||
a = addrinfo_s_allocate(rb_cAddrinfo);
|
||||
DATA_PTR(a) = rai = alloc_addrinfo();
|
||||
init_addrinfo(rai, addr, len, family, socktype, protocol, canonname, inspectname);
|
||||
return a;
|
||||
|
@ -740,12 +740,12 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* AddrInfo.new(sockaddr) => addrinfo
|
||||
* AddrInfo.new(sockaddr, family) => addrinfo
|
||||
* AddrInfo.new(sockaddr, family, socktype) => addrinfo
|
||||
* AddrInfo.new(sockaddr, family, socktype, protocol) => addrinfo
|
||||
* Addrinfo.new(sockaddr) => addrinfo
|
||||
* Addrinfo.new(sockaddr, family) => addrinfo
|
||||
* Addrinfo.new(sockaddr, family, socktype) => addrinfo
|
||||
* Addrinfo.new(sockaddr, family, socktype, protocol) => addrinfo
|
||||
*
|
||||
* returns a new instance of AddrInfo.
|
||||
* returns a new instance of Addrinfo.
|
||||
* It the instnace contains sockaddr, family, socktype, protocol.
|
||||
* sockaddr means struct sockaddr which can be used for connect(2), etc.
|
||||
* family, socktype and protocol are integers which is used for arguments of socket(2).
|
||||
|
@ -765,8 +765,8 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path)
|
|||
* - Socket.sockaddr_un("/tmp/sock")
|
||||
*
|
||||
* In an AF_INET/AF_INET6 sockaddr array, the 4th element,
|
||||
* numeric IP address, is used to construct socket address in the AddrInfo instance.
|
||||
* The 3rd element, textual host name, is also recorded but only used for AddrInfo#inspect.
|
||||
* numeric IP address, is used to construct socket address in the Addrinfo instance.
|
||||
* The 3rd element, textual host name, is also recorded but only used for Addrinfo#inspect.
|
||||
*
|
||||
* family is specified as an integer to specify the protocol family such as Socket::PF_INET.
|
||||
* It can be a symbol or a string which is the constant name
|
||||
|
@ -1018,8 +1018,8 @@ inspect_sockaddr(VALUE addrinfo, VALUE ret)
|
|||
*
|
||||
* returns a string which shows addrinfo in human-readable form.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).inspect #=> "#<AddrInfo: 127.0.0.1:80 TCP (localhost:80)>"
|
||||
* AddrInfo.unix("/tmp/sock").inspect #=> "#<AddrInfo: /tmp/sock SOCK_STREAM>"
|
||||
* Addrinfo.tcp("localhost", 80).inspect #=> "#<Addrinfo: 127.0.0.1:80 TCP (localhost:80)>"
|
||||
* Addrinfo.unix("/tmp/sock").inspect #=> "#<Addrinfo: /tmp/sock SOCK_STREAM>"
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1097,9 +1097,9 @@ addrinfo_inspect(VALUE self)
|
|||
*
|
||||
* returns a string which shows the sockaddr in _addrinfo_ with human-readable form.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80"
|
||||
* AddrInfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80"
|
||||
* AddrInfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock"
|
||||
* Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80"
|
||||
* Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80"
|
||||
* Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock"
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1299,7 +1299,7 @@ addrinfo_mload(VALUE self, VALUE ary)
|
|||
*
|
||||
* returns the address family as an integer.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true
|
||||
* Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1315,7 +1315,7 @@ addrinfo_afamily(VALUE self)
|
|||
*
|
||||
* returns the protocol family as an integer.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true
|
||||
* Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1331,7 +1331,7 @@ addrinfo_pfamily(VALUE self)
|
|||
*
|
||||
* returns the socket type as an integer.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true
|
||||
* Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1347,7 +1347,7 @@ addrinfo_socktype(VALUE self)
|
|||
*
|
||||
* returns the socket type as an integer.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true
|
||||
* Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1363,7 +1363,7 @@ addrinfo_protocol(VALUE self)
|
|||
*
|
||||
* returns the socket address as packed struct sockaddr string.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", 80).to_sockaddr
|
||||
* Addrinfo.tcp("localhost", 80).to_sockaddr
|
||||
* #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
*
|
||||
*/
|
||||
|
@ -1385,10 +1385,10 @@ addrinfo_to_sockaddr(VALUE self)
|
|||
*
|
||||
* nil is returned if no canonical name.
|
||||
*
|
||||
* The canonical name is set by AddrInfo.getaddrinfo when AI_CANONNAME is specified.
|
||||
* The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is specified.
|
||||
*
|
||||
* list = AddrInfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
|
||||
* p list[0] #=> #<AddrInfo: 221.186.184.68:80 TCP carbon.ruby-lang.org (www.ruby-lang.org:80)>
|
||||
* list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
|
||||
* p list[0] #=> #<Addrinfo: 221.186.184.68:80 TCP carbon.ruby-lang.org (www.ruby-lang.org:80)>
|
||||
* p list[0].canonname #=> "carbon.ruby-lang.org"
|
||||
*
|
||||
*/
|
||||
|
@ -1406,9 +1406,9 @@ addrinfo_canonname(VALUE self)
|
|||
* returns true if addrinfo is internet (IPv4/IPv6) address.
|
||||
* returns false otherwise.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).ip? #=> true
|
||||
* AddrInfo.tcp("::1", 80).ip? #=> true
|
||||
* AddrInfo.unix("/tmp/sock").ip? #=> false
|
||||
* Addrinfo.tcp("127.0.0.1", 80).ip? #=> true
|
||||
* Addrinfo.tcp("::1", 80).ip? #=> true
|
||||
* Addrinfo.unix("/tmp/sock").ip? #=> false
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1426,9 +1426,9 @@ addrinfo_ip_p(VALUE self)
|
|||
* returns true if addrinfo is IPv4 address.
|
||||
* returns false otherwise.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).ipv4? #=> true
|
||||
* AddrInfo.tcp("::1", 80).ipv4? #=> false
|
||||
* AddrInfo.unix("/tmp/sock").ipv4? #=> false
|
||||
* Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true
|
||||
* Addrinfo.tcp("::1", 80).ipv4? #=> false
|
||||
* Addrinfo.unix("/tmp/sock").ipv4? #=> false
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1445,9 +1445,9 @@ addrinfo_ipv4_p(VALUE self)
|
|||
* returns true if addrinfo is IPv6 address.
|
||||
* returns false otherwise.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).ipv6? #=> false
|
||||
* AddrInfo.tcp("::1", 80).ipv6? #=> true
|
||||
* AddrInfo.unix("/tmp/sock").ipv6? #=> false
|
||||
* Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false
|
||||
* Addrinfo.tcp("::1", 80).ipv6? #=> true
|
||||
* Addrinfo.unix("/tmp/sock").ipv6? #=> false
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1468,9 +1468,9 @@ addrinfo_ipv6_p(VALUE self)
|
|||
* returns true if addrinfo is UNIX address.
|
||||
* returns false otherwise.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).unix? #=> false
|
||||
* AddrInfo.tcp("::1", 80).unix? #=> false
|
||||
* AddrInfo.unix("/tmp/sock").unix? #=> true
|
||||
* Addrinfo.tcp("127.0.0.1", 80).unix? #=> false
|
||||
* Addrinfo.tcp("::1", 80).unix? #=> false
|
||||
* Addrinfo.unix("/tmp/sock").unix? #=> true
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1494,9 +1494,9 @@ addrinfo_unix_p(VALUE self)
|
|||
*
|
||||
* flags should be bitwise OR of Socket::NI_??? constants.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"]
|
||||
* Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"]
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV)
|
||||
* Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV)
|
||||
* #=> ["localhost", "80"]
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1530,8 +1530,8 @@ addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self)
|
|||
*
|
||||
* Returns the IP address and port number as 2-element array.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80]
|
||||
* AddrInfo.tcp("::1", 80).ip_unpack #=> ["::1", 80]
|
||||
* Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80]
|
||||
* Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80]
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_ip_unpack(VALUE self)
|
||||
|
@ -1557,8 +1557,8 @@ addrinfo_ip_unpack(VALUE self)
|
|||
*
|
||||
* Returns the IP address as a string.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1"
|
||||
* AddrInfo.tcp("::1", 80).ip_address #=> "::1"
|
||||
* Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1"
|
||||
* Addrinfo.tcp("::1", 80).ip_address #=> "::1"
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_ip_address(VALUE self)
|
||||
|
@ -1582,8 +1582,8 @@ addrinfo_ip_address(VALUE self)
|
|||
*
|
||||
* Returns the port number as an integer.
|
||||
*
|
||||
* AddrInfo.tcp("127.0.0.1", 80).ip_port #=> 80
|
||||
* AddrInfo.tcp("::1", 80).ip_port #=> 80
|
||||
* Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80
|
||||
* Addrinfo.tcp("::1", 80).ip_port #=> 80
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_ip_port(VALUE self)
|
||||
|
@ -1836,11 +1836,11 @@ addrinfo_ipv6_mc_global_p(VALUE self)
|
|||
* Returns IPv4 address of IPv4 mapped/compatible IPv6 address.
|
||||
* It returns nil if +self+ is not IPv4 mapped/compatible IPv6 address.
|
||||
*
|
||||
* AddrInfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> #<AddrInfo: 192.0.2.3>
|
||||
* AddrInfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> #<AddrInfo: 192.0.2.3>
|
||||
* AddrInfo.ip("::1").ipv6_to_ipv4 #=> nil
|
||||
* AddrInfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil
|
||||
* AddrInfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil
|
||||
* Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
|
||||
* Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
|
||||
* Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil
|
||||
* Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil
|
||||
* Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_ipv6_to_ipv4(VALUE self)
|
||||
|
@ -1874,7 +1874,7 @@ addrinfo_ipv6_to_ipv4(VALUE self)
|
|||
*
|
||||
* Returns the socket path as a string.
|
||||
*
|
||||
* AddrInfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
|
||||
* Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_unix_path(VALUE self)
|
||||
|
@ -1903,11 +1903,11 @@ addrinfo_unix_path(VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* AddrInfo.getaddrinfo(nodename, service, family, socktype, protocol, flags) => [addrinfo, ...]
|
||||
* AddrInfo.getaddrinfo(nodename, service, family, socktype, protocol) => [addrinfo, ...]
|
||||
* AddrInfo.getaddrinfo(nodename, service, family, socktype) => [addrinfo, ...]
|
||||
* AddrInfo.getaddrinfo(nodename, service, family) => [addrinfo, ...]
|
||||
* AddrInfo.getaddrinfo(nodename, service) => [addrinfo, ...]
|
||||
* Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags) => [addrinfo, ...]
|
||||
* Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol) => [addrinfo, ...]
|
||||
* Addrinfo.getaddrinfo(nodename, service, family, socktype) => [addrinfo, ...]
|
||||
* Addrinfo.getaddrinfo(nodename, service, family) => [addrinfo, ...]
|
||||
* Addrinfo.getaddrinfo(nodename, service) => [addrinfo, ...]
|
||||
*
|
||||
* returns a list of addrinfo objects as an array.
|
||||
*
|
||||
|
@ -1919,7 +1919,7 @@ addrinfo_unix_path(VALUE self)
|
|||
* family, socktype and protocol are hint for prefered protocol.
|
||||
* If the result will be used for a socket with SOCK_STREAM,
|
||||
* SOCK_STREAM should be specified as socktype.
|
||||
* If so, AddrInfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM.
|
||||
* If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM.
|
||||
* If they are omitted or nil is given, the result is not restricted.
|
||||
*
|
||||
* Similary, PF_INET6 as family restricts for IPv6.
|
||||
|
@ -1930,9 +1930,9 @@ addrinfo_unix_path(VALUE self)
|
|||
* Some platform causes an error when socktype is ommitted and servname is specified as an integer
|
||||
* because some port numbers, 512 for example, are ambiguous without socktype.
|
||||
*
|
||||
* AddrInfo.getaddrinfo("www.kame.net", 80, nil, :STREAM)
|
||||
* #=> [#<AddrInfo: 203.178.141.194:80 TCP (www.kame.net:80)>,
|
||||
* # #<AddrInfo: [2001:200:0:8002:203:47ff:fea5:3085]:80 TCP (www.kame.net:80)>]
|
||||
* Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM)
|
||||
* #=> [#<Addrinfo: 203.178.141.194:80 TCP (www.kame.net:80)>,
|
||||
* # #<Addrinfo: [2001:200:0:8002:203:47ff:fea5:3085]:80 TCP (www.kame.net:80)>]
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1946,14 +1946,14 @@ addrinfo_s_getaddrinfo(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* AddrInfo.ip(host) => addrinfo
|
||||
* Addrinfo.ip(host) => addrinfo
|
||||
*
|
||||
* returns an addrinfo object for IP address.
|
||||
*
|
||||
* The port, socktype, protocol of the result is filled by zero.
|
||||
* So, it is not appropriate to create a socket.
|
||||
*
|
||||
* AddrInfo.ip("localhost") #=> #<AddrInfo: 127.0.0.1 (localhost)>
|
||||
* Addrinfo.ip("localhost") #=> #<Addrinfo: 127.0.0.1 (localhost)>
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_s_ip(VALUE self, VALUE host)
|
||||
|
@ -1970,11 +1970,11 @@ addrinfo_s_ip(VALUE self, VALUE host)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* AddrInfo.tcp(host, port) => addrinfo
|
||||
* Addrinfo.tcp(host, port) => addrinfo
|
||||
*
|
||||
* returns an addrinfo object for TCP address.
|
||||
*
|
||||
* AddrInfo.tcp("localhost", "smtp") #=> #<AddrInfo: 127.0.0.1:25 TCP (localhost:smtp)>
|
||||
* Addrinfo.tcp("localhost", "smtp") #=> #<Addrinfo: 127.0.0.1:25 TCP (localhost:smtp)>
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_s_tcp(VALUE self, VALUE host, VALUE port)
|
||||
|
@ -1985,11 +1985,11 @@ addrinfo_s_tcp(VALUE self, VALUE host, VALUE port)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* AddrInfo.udp(host, port) => addrinfo
|
||||
* Addrinfo.udp(host, port) => addrinfo
|
||||
*
|
||||
* returns an addrinfo object for UDP address.
|
||||
*
|
||||
* AddrInfo.udp("localhost", "daytime") #=> #<AddrInfo: 127.0.0.1:13 UDP (localhost:daytime)>
|
||||
* Addrinfo.udp("localhost", "daytime") #=> #<Addrinfo: 127.0.0.1:13 UDP (localhost:daytime)>
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_s_udp(VALUE self, VALUE host, VALUE port)
|
||||
|
@ -2002,11 +2002,11 @@ addrinfo_s_udp(VALUE self, VALUE host, VALUE port)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* AddrInfo.udp(host, port) => addrinfo
|
||||
* Addrinfo.udp(host, port) => addrinfo
|
||||
*
|
||||
* returns an addrinfo object for UNIX socket address.
|
||||
*
|
||||
* AddrInfo.unix("/tmp/sock") #=> #<AddrInfo: /tmp/sock SOCK_STREAM>
|
||||
* Addrinfo.unix("/tmp/sock") #=> #<Addrinfo: /tmp/sock SOCK_STREAM>
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_s_unix(VALUE self, VALUE path)
|
||||
|
@ -2014,7 +2014,7 @@ addrinfo_s_unix(VALUE self, VALUE path)
|
|||
VALUE addr;
|
||||
rb_addrinfo_t *rai;
|
||||
|
||||
addr = addrinfo_s_allocate(rb_cAddrInfo);
|
||||
addr = addrinfo_s_allocate(rb_cAddrinfo);
|
||||
DATA_PTR(addr) = rai = alloc_addrinfo();
|
||||
init_unix_addrinfo(rai, path);
|
||||
OBJ_INFECT(addr, path);
|
||||
|
@ -2090,69 +2090,69 @@ io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
|
|||
}
|
||||
|
||||
/*
|
||||
* AddrInfo class
|
||||
* Addrinfo class
|
||||
*/
|
||||
void
|
||||
Init_addrinfo(void)
|
||||
{
|
||||
rb_cAddrInfo = rb_define_class("AddrInfo", rb_cData);
|
||||
rb_define_alloc_func(rb_cAddrInfo, addrinfo_s_allocate);
|
||||
rb_define_method(rb_cAddrInfo, "initialize", addrinfo_initialize, -1);
|
||||
rb_define_method(rb_cAddrInfo, "inspect", addrinfo_inspect, 0);
|
||||
rb_define_method(rb_cAddrInfo, "inspect_sockaddr", addrinfo_inspect_sockaddr, 0);
|
||||
rb_define_singleton_method(rb_cAddrInfo, "getaddrinfo", addrinfo_s_getaddrinfo, -1);
|
||||
rb_define_singleton_method(rb_cAddrInfo, "ip", addrinfo_s_ip, 1);
|
||||
rb_define_singleton_method(rb_cAddrInfo, "tcp", addrinfo_s_tcp, 2);
|
||||
rb_define_singleton_method(rb_cAddrInfo, "udp", addrinfo_s_udp, 2);
|
||||
rb_cAddrinfo = rb_define_class("Addrinfo", rb_cData);
|
||||
rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
|
||||
rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
|
||||
rb_define_method(rb_cAddrinfo, "inspect", addrinfo_inspect, 0);
|
||||
rb_define_method(rb_cAddrinfo, "inspect_sockaddr", addrinfo_inspect_sockaddr, 0);
|
||||
rb_define_singleton_method(rb_cAddrinfo, "getaddrinfo", addrinfo_s_getaddrinfo, -1);
|
||||
rb_define_singleton_method(rb_cAddrinfo, "ip", addrinfo_s_ip, 1);
|
||||
rb_define_singleton_method(rb_cAddrinfo, "tcp", addrinfo_s_tcp, 2);
|
||||
rb_define_singleton_method(rb_cAddrinfo, "udp", addrinfo_s_udp, 2);
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
rb_define_singleton_method(rb_cAddrInfo, "unix", addrinfo_s_unix, 1);
|
||||
rb_define_singleton_method(rb_cAddrinfo, "unix", addrinfo_s_unix, 1);
|
||||
#endif
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "afamily", addrinfo_afamily, 0);
|
||||
rb_define_method(rb_cAddrInfo, "pfamily", addrinfo_pfamily, 0);
|
||||
rb_define_method(rb_cAddrInfo, "socktype", addrinfo_socktype, 0);
|
||||
rb_define_method(rb_cAddrInfo, "protocol", addrinfo_protocol, 0);
|
||||
rb_define_method(rb_cAddrInfo, "canonname", addrinfo_canonname, 0);
|
||||
rb_define_method(rb_cAddrinfo, "afamily", addrinfo_afamily, 0);
|
||||
rb_define_method(rb_cAddrinfo, "pfamily", addrinfo_pfamily, 0);
|
||||
rb_define_method(rb_cAddrinfo, "socktype", addrinfo_socktype, 0);
|
||||
rb_define_method(rb_cAddrinfo, "protocol", addrinfo_protocol, 0);
|
||||
rb_define_method(rb_cAddrinfo, "canonname", addrinfo_canonname, 0);
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "ipv4?", addrinfo_ipv4_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6?", addrinfo_ipv6_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "unix?", addrinfo_unix_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv4?", addrinfo_ipv4_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6?", addrinfo_ipv6_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "unix?", addrinfo_unix_p, 0);
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "ip?", addrinfo_ip_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ip_unpack", addrinfo_ip_unpack, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ip_address", addrinfo_ip_address, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ip_port", addrinfo_ip_port, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ip?", addrinfo_ip_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ip_unpack", addrinfo_ip_unpack, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ip_address", addrinfo_ip_address, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ip_port", addrinfo_ip_port, 0);
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "ipv4_private?", addrinfo_ipv4_private_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv4_loopback?", addrinfo_ipv4_loopback_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv4_multicast?", addrinfo_ipv4_multicast_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv4_private?", addrinfo_ipv4_private_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv4_loopback?", addrinfo_ipv4_loopback_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv4_multicast?", addrinfo_ipv4_multicast_p, 0);
|
||||
|
||||
#ifdef INET6
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_unspecified?", addrinfo_ipv6_unspecified_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_loopback?", addrinfo_ipv6_loopback_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_multicast?", addrinfo_ipv6_multicast_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_linklocal?", addrinfo_ipv6_linklocal_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_sitelocal?", addrinfo_ipv6_sitelocal_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_v4mapped?", addrinfo_ipv6_v4mapped_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_v4compat?", addrinfo_ipv6_v4compat_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_mc_nodelocal?", addrinfo_ipv6_mc_nodelocal_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_mc_linklocal?", addrinfo_ipv6_mc_linklocal_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_mc_sitelocal?", addrinfo_ipv6_mc_sitelocal_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_mc_orglocal?", addrinfo_ipv6_mc_orglocal_p, 0);
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_mc_global?", addrinfo_ipv6_mc_global_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_unspecified?", addrinfo_ipv6_unspecified_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_loopback?", addrinfo_ipv6_loopback_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_multicast?", addrinfo_ipv6_multicast_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_linklocal?", addrinfo_ipv6_linklocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_sitelocal?", addrinfo_ipv6_sitelocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_v4mapped?", addrinfo_ipv6_v4mapped_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_v4compat?", addrinfo_ipv6_v4compat_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_mc_nodelocal?", addrinfo_ipv6_mc_nodelocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_mc_linklocal?", addrinfo_ipv6_mc_linklocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_mc_sitelocal?", addrinfo_ipv6_mc_sitelocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_mc_orglocal?", addrinfo_ipv6_mc_orglocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_mc_global?", addrinfo_ipv6_mc_global_p, 0);
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "ipv6_to_ipv4", addrinfo_ipv6_to_ipv4, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_to_ipv4", addrinfo_ipv6_to_ipv4, 0);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
rb_define_method(rb_cAddrInfo, "unix_path", addrinfo_unix_path, 0);
|
||||
rb_define_method(rb_cAddrinfo, "unix_path", addrinfo_unix_path, 0);
|
||||
#endif
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "to_sockaddr", addrinfo_to_sockaddr, 0);
|
||||
rb_define_method(rb_cAddrInfo, "to_s", addrinfo_to_sockaddr, 0); /* compatibility for ruby before 1.9.2 */
|
||||
rb_define_method(rb_cAddrinfo, "to_sockaddr", addrinfo_to_sockaddr, 0);
|
||||
rb_define_method(rb_cAddrinfo, "to_s", addrinfo_to_sockaddr, 0); /* compatibility for ruby before 1.9.2 */
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "getnameinfo", addrinfo_getnameinfo, -1);
|
||||
rb_define_method(rb_cAddrinfo, "getnameinfo", addrinfo_getnameinfo, -1);
|
||||
|
||||
rb_define_method(rb_cAddrInfo, "marshal_dump", addrinfo_mdump, 0);
|
||||
rb_define_method(rb_cAddrInfo, "marshal_load", addrinfo_mload, 1);
|
||||
rb_define_method(rb_cAddrinfo, "marshal_dump", addrinfo_mdump, 0);
|
||||
rb_define_method(rb_cAddrinfo, "marshal_load", addrinfo_mload, 1);
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ extern VALUE rb_cUNIXSocket;
|
|||
extern VALUE rb_cUNIXServer;
|
||||
#endif
|
||||
extern VALUE rb_cSocket;
|
||||
extern VALUE rb_cAddrInfo;
|
||||
extern VALUE rb_cAddrinfo;
|
||||
extern VALUE rb_cSockOpt;
|
||||
|
||||
extern VALUE rb_eSocket;
|
||||
|
|
|
@ -674,13 +674,13 @@ sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
|
|||
* socket.accept => [client_socket, client_addrinfo]
|
||||
*
|
||||
* Accepts a next connection.
|
||||
* Returns a new Socket object and AddrInfo object.
|
||||
* Returns a new Socket object and Addrinfo object.
|
||||
*
|
||||
* serv = Socket.new(:INET, :STREAM, 0)
|
||||
* serv.listen(5)
|
||||
* c = Socket.new(:INET, :STREAM, 0)
|
||||
* c.connect(serv.local_address)
|
||||
* p serv.accept #=> [#<Socket:fd 6>, #<AddrInfo: 127.0.0.1:48555 TCP>]
|
||||
* p serv.accept #=> [#<Socket:fd 6>, #<Addrinfo: 127.0.0.1:48555 TCP>]
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
|
@ -1442,12 +1442,12 @@ sockaddr_obj(struct sockaddr *addr)
|
|||
*
|
||||
* Returns local IP addresses as an array.
|
||||
*
|
||||
* The array contains AddrInfo objects.
|
||||
* The array contains Addrinfo objects.
|
||||
*
|
||||
* pp Socket.ip_address_list
|
||||
* #=> [#<AddrInfo: 127.0.0.1>,
|
||||
* #<AddrInfo: 192.168.0.128>,
|
||||
* #<AddrInfo: ::1>,
|
||||
* #=> [#<Addrinfo: 127.0.0.1>,
|
||||
* #<Addrinfo: 192.168.0.128>,
|
||||
* #<Addrinfo: ::1>,
|
||||
* ...]
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -129,11 +129,11 @@ unix_path(VALUE sock)
|
|||
* _flags_ should be a bitwise OR of Socket::MSG_* constants.
|
||||
*
|
||||
* s1 = Socket.new(:UNIX, :DGRAM, 0)
|
||||
* s1_ai = AddrInfo.unix("/tmp/sock1")
|
||||
* s1_ai = Addrinfo.unix("/tmp/sock1")
|
||||
* s1.bind(s1_ai)
|
||||
*
|
||||
* s2 = Socket.new(:UNIX, :DGRAM, 0)
|
||||
* s2_ai = AddrInfo.unix("/tmp/sock2")
|
||||
* s2_ai = Addrinfo.unix("/tmp/sock2")
|
||||
* s2.bind(s2_ai)
|
||||
* s3 = UNIXSocket.for_fd(s2.fileno)
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue