rbs 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -1
- data/.gitignore +2 -0
- data/CHANGELOG.md +81 -0
- data/README.md +1 -1
- data/Rakefile +11 -0
- data/Steepfile +1 -0
- data/core/array.rbs +2 -2
- data/core/basic_object.rbs +1 -1
- data/core/enumerable.rbs +1 -1
- data/core/hash.rbs +13 -5
- data/core/io.rbs +4 -4
- data/core/kernel.rbs +2 -2
- data/core/marshal.rbs +4 -3
- data/core/module.rbs +1 -1
- data/core/numeric.rbs +10 -0
- data/core/proc.rbs +1 -1
- data/core/random.rbs +4 -2
- data/core/range.rbs +2 -2
- data/core/struct.rbs +3 -2
- data/core/thread.rbs +1 -1
- data/docs/CONTRIBUTING.md +5 -3
- data/docs/rbs_by_example.md +328 -0
- data/docs/sigs.md +21 -2
- data/docs/stdlib.md +1 -1
- data/docs/syntax.md +11 -14
- data/lib/rbs.rb +1 -0
- data/lib/rbs/ast/annotation.rb +2 -2
- data/lib/rbs/ast/comment.rb +2 -2
- data/lib/rbs/ast/declarations.rb +37 -22
- data/lib/rbs/ast/members.rb +26 -26
- data/lib/rbs/cli.rb +3 -0
- data/lib/rbs/constant_table.rb +4 -1
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder.rb +16 -18
- data/lib/rbs/definition_builder/ancestor_builder.rb +10 -2
- data/lib/rbs/definition_builder/method_builder.rb +4 -2
- data/lib/rbs/errors.rb +36 -0
- data/lib/rbs/location.rb +106 -2
- data/lib/rbs/locator.rb +205 -0
- data/lib/rbs/method_type.rb +2 -2
- data/lib/rbs/parser.rb +1315 -962
- data/lib/rbs/parser.y +411 -75
- data/lib/rbs/prototype/rb.rb +7 -3
- data/lib/rbs/prototype/runtime.rb +118 -42
- data/lib/rbs/test/hook.rb +8 -2
- data/lib/rbs/type_name.rb +2 -3
- data/lib/rbs/type_name_resolver.rb +1 -1
- data/lib/rbs/types.rb +36 -34
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -2
- data/rbs.gemspec +1 -1
- data/sig/ancestor_builder.rbs +2 -0
- data/sig/annotation.rbs +1 -1
- data/sig/cli.rbs +31 -21
- data/sig/comment.rbs +1 -1
- data/sig/declarations.rbs +106 -21
- data/sig/environment.rbs +2 -2
- data/sig/errors.rbs +15 -0
- data/sig/location.rbs +84 -3
- data/sig/locator.rbs +44 -0
- data/sig/members.rbs +76 -12
- data/sig/method_builder.rbs +1 -1
- data/sig/method_types.rbs +1 -1
- data/sig/namespace.rbs +1 -1
- data/sig/polyfill.rbs +4 -17
- data/sig/rbs.rbs +8 -4
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +67 -20
- data/sig/util.rbs +0 -4
- data/sig/writer.rbs +8 -2
- data/stdlib/dbm/0/dbm.rbs +43 -30
- data/stdlib/mutex_m/0/mutex_m.rbs +1 -1
- data/stdlib/net-http/0/net-http.rbs +1846 -0
- data/stdlib/optparse/0/optparse.rbs +1214 -0
- data/stdlib/resolv/0/resolv.rbs +1504 -0
- data/stdlib/rubygems/0/requirement.rbs +84 -2
- data/stdlib/rubygems/0/rubygems.rbs +2 -2
- data/stdlib/rubygems/0/version.rbs +2 -1
- data/stdlib/shellwords/0/shellwords.rbs +252 -0
- data/stdlib/socket/0/addrinfo.rbs +469 -0
- data/stdlib/socket/0/basic_socket.rbs +503 -0
- data/stdlib/socket/0/ip_socket.rbs +72 -0
- data/stdlib/socket/0/socket.rbs +2687 -0
- data/stdlib/socket/0/tcp_server.rbs +177 -0
- data/stdlib/socket/0/tcp_socket.rbs +35 -0
- data/stdlib/socket/0/udp_socket.rbs +111 -0
- data/stdlib/socket/0/unix_server.rbs +154 -0
- data/stdlib/socket/0/unix_socket.rbs +132 -0
- data/stdlib/timeout/0/timeout.rbs +5 -0
- data/steep/Gemfile.lock +19 -16
- metadata +18 -11
- data/bin/annotate-with-rdoc +0 -153
- data/bin/console +0 -14
- data/bin/query-rdoc +0 -103
- data/bin/rbs-prof +0 -9
- data/bin/run_in_md.rb +0 -49
- data/bin/setup +0 -8
- data/bin/sort +0 -89
- data/bin/steep +0 -4
- data/bin/test_runner.rb +0 -29
@@ -1,3 +1,85 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
module Gem
|
2
|
+
# A Requirement is a set of one or more version restrictions. It supports a few
|
3
|
+
# (`=, !=, >, <, >=, <=, ~>`) different restriction operators.
|
4
|
+
#
|
5
|
+
# See Gem::Version for a description on how versions and requirements work
|
6
|
+
# together in RubyGems.
|
7
|
+
#
|
8
|
+
class Requirement
|
9
|
+
type operator = "=" | "!=" | ">" | "<" | ">=" | "<=" | "~>"
|
10
|
+
|
11
|
+
# Raised when a bad requirement is encountered
|
12
|
+
#
|
13
|
+
class BadRequirementError < ArgumentError
|
14
|
+
end
|
15
|
+
|
16
|
+
# The default requirement matches any version
|
17
|
+
#
|
18
|
+
DefaultPrereleaseRequirement: [ operator, Gem::Version ]
|
19
|
+
|
20
|
+
# The default requirement matches any non-prerelease version
|
21
|
+
#
|
22
|
+
DefaultRequirement: [ operator, Gem::Version ]
|
23
|
+
|
24
|
+
# A regular expression that matches a requirement
|
25
|
+
#
|
26
|
+
PATTERN: Regexp
|
27
|
+
|
28
|
+
# Factory method to create a Gem::Requirement object. Input may be a Version, a
|
29
|
+
# String, or nil. Intended to simplify client code.
|
30
|
+
#
|
31
|
+
# If the input is "weird", the default version requirement is returned.
|
32
|
+
#
|
33
|
+
def self.create: (*(String | Gem::Version | Gem::Requirement | nil) inputs) -> instance
|
34
|
+
|
35
|
+
def self.default: () -> instance
|
36
|
+
|
37
|
+
def self.default_prerelease: () -> instance
|
38
|
+
|
39
|
+
# Parse `obj`, returning an `[op, version]` pair. `obj` can be a String or a
|
40
|
+
# Gem::Version.
|
41
|
+
#
|
42
|
+
# If `obj` is a String, it can be either a full requirement specification, like
|
43
|
+
# `">= 1.2"`, or a simple version number, like `"1.2"`.
|
44
|
+
#
|
45
|
+
# parse("> 1.0") # => [">", Gem::Version.new("1.0")]
|
46
|
+
# parse("1.0") # => ["=", Gem::Version.new("1.0")]
|
47
|
+
# parse(Gem::Version.new("1.0")) # => ["=, Gem::Version.new("1.0")]
|
48
|
+
#
|
49
|
+
def self.parse: (String | Gem::Version obj) -> [ operator, Gem::Version ]
|
50
|
+
|
51
|
+
# Constructs a requirement from `requirements`. Requirements can be Strings,
|
52
|
+
# Gem::Versions, or Arrays of those. `nil` and duplicate requirements are
|
53
|
+
# ignored. An empty set of `requirements` is the same as `">= 0"`.
|
54
|
+
#
|
55
|
+
def initialize: (*(String | Gem::Version) requirements) -> void
|
56
|
+
|
57
|
+
# Concatenates the `new` requirements onto this requirement.
|
58
|
+
#
|
59
|
+
def concat: (Array[String | Gem::Version] new) -> void
|
60
|
+
|
61
|
+
# true if the requirement is for only an exact version
|
62
|
+
#
|
63
|
+
def exact?: () -> bool
|
64
|
+
|
65
|
+
# true if this gem has no requirements.
|
66
|
+
#
|
67
|
+
def none?: () -> bool
|
68
|
+
|
69
|
+
# A requirement is a prerelease if any of the versions inside of it are
|
70
|
+
# prereleases
|
71
|
+
#
|
72
|
+
def prerelease?: () -> bool
|
73
|
+
|
74
|
+
# True if `version` satisfies this Requirement.
|
75
|
+
#
|
76
|
+
def satisfied_by?: (Gem::Version version) -> bool
|
77
|
+
|
78
|
+
alias === satisfied_by?
|
79
|
+
alias =~ satisfied_by?
|
80
|
+
|
81
|
+
# True if the requirement will not always match the latest version.
|
82
|
+
#
|
83
|
+
def specific?: () -> bool
|
84
|
+
end
|
3
85
|
end
|
@@ -338,7 +338,7 @@ module Gem
|
|
338
338
|
#
|
339
339
|
def self.find_unresolved_default_spec: (String path) -> Specification?
|
340
340
|
|
341
|
-
def self.finish_resolve: (?RequestSet request_set) ->
|
341
|
+
def self.finish_resolve: (?RequestSet request_set) -> void
|
342
342
|
|
343
343
|
# GemDependencyAPI object, which is set when .use_gemdeps is called. This
|
344
344
|
# contains all the information from the Gemfile.
|
@@ -417,7 +417,7 @@ module Gem
|
|
417
417
|
#
|
418
418
|
def self.marshal_version: () -> String
|
419
419
|
|
420
|
-
def self.needs: () { (RequestSet) ->
|
420
|
+
def self.needs: () { (RequestSet) -> void } -> void
|
421
421
|
|
422
422
|
# Default options for gem commands for Ruby packagers.
|
423
423
|
#
|
@@ -170,7 +170,8 @@ module Gem
|
|
170
170
|
# ver2 = Version.create(ver1) # -> (ver1)
|
171
171
|
# ver3 = Version.create(nil) # -> nil
|
172
172
|
#
|
173
|
-
def self.create: (_ToS | Version
|
173
|
+
def self.create: (_ToS | Version input) -> instance
|
174
|
+
| (nil input) -> nil
|
174
175
|
|
175
176
|
# Constructs a Version from the `version` string. A version string is a series
|
176
177
|
# of digits or ASCII letters separated by dots.
|
@@ -0,0 +1,252 @@
|
|
1
|
+
# ## Manipulates strings like the UNIX Bourne shell
|
2
|
+
#
|
3
|
+
# This module manipulates strings according to the word parsing rules of the
|
4
|
+
# UNIX Bourne shell.
|
5
|
+
#
|
6
|
+
# The shellwords() function was originally a port of shellwords.pl, but modified
|
7
|
+
# to conform to the Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016
|
8
|
+
# Edition [1].
|
9
|
+
#
|
10
|
+
# ### Usage
|
11
|
+
#
|
12
|
+
# You can use Shellwords to parse a string into a Bourne shell friendly Array.
|
13
|
+
#
|
14
|
+
# require 'shellwords'
|
15
|
+
#
|
16
|
+
# argv = Shellwords.split('three blind "mice"')
|
17
|
+
# argv #=> ["three", "blind", "mice"]
|
18
|
+
#
|
19
|
+
# Once you've required Shellwords, you can use the #split alias
|
20
|
+
# String#shellsplit.
|
21
|
+
#
|
22
|
+
# argv = "see how they run".shellsplit
|
23
|
+
# argv #=> ["see", "how", "they", "run"]
|
24
|
+
#
|
25
|
+
# They treat quotes as special characters, so an unmatched quote will cause an
|
26
|
+
# ArgumentError.
|
27
|
+
#
|
28
|
+
# argv = "they all ran after the farmer's wife".shellsplit
|
29
|
+
# #=> ArgumentError: Unmatched quote: ...
|
30
|
+
#
|
31
|
+
# Shellwords also provides methods that do the opposite. Shellwords.escape, or
|
32
|
+
# its alias, String#shellescape, escapes shell metacharacters in a string for
|
33
|
+
# use in a command line.
|
34
|
+
#
|
35
|
+
# filename = "special's.txt"
|
36
|
+
#
|
37
|
+
# system("cat -- #{filename.shellescape}")
|
38
|
+
# # runs "cat -- special\\'s.txt"
|
39
|
+
#
|
40
|
+
# Note the '--'. Without it, cat(1) will treat the following argument as a
|
41
|
+
# command line option if it starts with '-'. It is guaranteed that
|
42
|
+
# Shellwords.escape converts a string to a form that a Bourne shell will parse
|
43
|
+
# back to the original string, but it is the programmer's responsibility to make
|
44
|
+
# sure that passing an arbitrary argument to a command does no harm.
|
45
|
+
#
|
46
|
+
# Shellwords also comes with a core extension for Array, Array#shelljoin.
|
47
|
+
#
|
48
|
+
# dir = "Funny GIFs"
|
49
|
+
# argv = %W[ls -lta -- #{dir}]
|
50
|
+
# system(argv.shelljoin + " | less")
|
51
|
+
# # runs "ls -lta -- Funny\\ GIFs | less"
|
52
|
+
#
|
53
|
+
# You can use this method to build a complete command line out of an array of
|
54
|
+
# arguments.
|
55
|
+
#
|
56
|
+
# ### Authors
|
57
|
+
# * Wakou Aoyama
|
58
|
+
# * Akinori MUSHA <knu@iDaemons.org>
|
59
|
+
#
|
60
|
+
#
|
61
|
+
# ### Contact
|
62
|
+
# * Akinori MUSHA <knu@iDaemons.org> (current maintainer)
|
63
|
+
#
|
64
|
+
#
|
65
|
+
# ### Resources
|
66
|
+
#
|
67
|
+
# 1: [IEEE Std 1003.1-2008, 2016 Edition, the Shell & Utilities
|
68
|
+
# volume](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.htm
|
69
|
+
# l)
|
70
|
+
module Shellwords
|
71
|
+
# Escapes a string so that it can be safely used in a Bourne shell command line.
|
72
|
+
# `str` can be a non-string object that responds to `to_s`.
|
73
|
+
#
|
74
|
+
# Note that a resulted string should be used unquoted and is not intended for
|
75
|
+
# use in double quotes nor in single quotes.
|
76
|
+
#
|
77
|
+
# argv = Shellwords.escape("It's better to give than to receive")
|
78
|
+
# argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
|
79
|
+
#
|
80
|
+
# String#shellescape is a shorthand for this function.
|
81
|
+
#
|
82
|
+
# argv = "It's better to give than to receive".shellescape
|
83
|
+
# argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
|
84
|
+
#
|
85
|
+
# # Search files in lib for method definitions
|
86
|
+
# pattern = "^[ \t]*def "
|
87
|
+
# open("| grep -Ern -e #{pattern.shellescape} lib") { |grep|
|
88
|
+
# grep.each_line { |line|
|
89
|
+
# file, lineno, matched_line = line.split(':', 3)
|
90
|
+
# # ...
|
91
|
+
# }
|
92
|
+
# }
|
93
|
+
#
|
94
|
+
# It is the caller's responsibility to encode the string in the right encoding
|
95
|
+
# for the shell environment where this string is used.
|
96
|
+
#
|
97
|
+
# Multibyte characters are treated as multibyte characters, not as bytes.
|
98
|
+
#
|
99
|
+
# Returns an empty quoted String if `str` has a length of zero.
|
100
|
+
#
|
101
|
+
def self.shellescape: (String str) -> String
|
102
|
+
|
103
|
+
# Builds a command line string from an argument list, `array`.
|
104
|
+
#
|
105
|
+
# All elements are joined into a single string with fields separated by a space,
|
106
|
+
# where each element is escaped for the Bourne shell and stringified using
|
107
|
+
# `to_s`.
|
108
|
+
#
|
109
|
+
# ary = ["There's", "a", "time", "and", "place", "for", "everything"]
|
110
|
+
# argv = Shellwords.join(ary)
|
111
|
+
# argv #=> "There\\'s a time and place for everything"
|
112
|
+
#
|
113
|
+
# Array#shelljoin is a shortcut for this function.
|
114
|
+
#
|
115
|
+
# ary = ["Don't", "rock", "the", "boat"]
|
116
|
+
# argv = ary.shelljoin
|
117
|
+
# argv #=> "Don\\'t rock the boat"
|
118
|
+
#
|
119
|
+
# You can also mix non-string objects in the elements as allowed in Array#join.
|
120
|
+
#
|
121
|
+
# output = `#{['ps', '-p', $$].shelljoin}`
|
122
|
+
#
|
123
|
+
def self.shelljoin: (Array[String] array) -> String
|
124
|
+
|
125
|
+
# Splits a string into an array of tokens in the same way the UNIX Bourne shell
|
126
|
+
# does.
|
127
|
+
#
|
128
|
+
# argv = Shellwords.split('here are "two words"')
|
129
|
+
# argv #=> ["here", "are", "two words"]
|
130
|
+
#
|
131
|
+
# Note, however, that this is not a command line parser. Shell metacharacters
|
132
|
+
# except for the single and double quotes and backslash are not treated as such.
|
133
|
+
#
|
134
|
+
# argv = Shellwords.split('ruby my_prog.rb | less')
|
135
|
+
# argv #=> ["ruby", "my_prog.rb", "|", "less"]
|
136
|
+
#
|
137
|
+
# String#shellsplit is a shortcut for this function.
|
138
|
+
#
|
139
|
+
# argv = 'here are "two words"'.shellsplit
|
140
|
+
# argv #=> ["here", "are", "two words"]
|
141
|
+
#
|
142
|
+
def self.shellsplit: (String line) -> Array[String]
|
143
|
+
|
144
|
+
alias self.escape self.shellescape
|
145
|
+
|
146
|
+
alias self.join self.shelljoin
|
147
|
+
|
148
|
+
alias self.shellwords self.shellsplit
|
149
|
+
|
150
|
+
alias self.split self.shellsplit
|
151
|
+
|
152
|
+
private
|
153
|
+
|
154
|
+
# Escapes a string so that it can be safely used in a Bourne shell command line.
|
155
|
+
# `str` can be a non-string object that responds to `to_s`.
|
156
|
+
#
|
157
|
+
# Note that a resulted string should be used unquoted and is not intended for
|
158
|
+
# use in double quotes nor in single quotes.
|
159
|
+
#
|
160
|
+
# argv = Shellwords.escape("It's better to give than to receive")
|
161
|
+
# argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
|
162
|
+
#
|
163
|
+
# String#shellescape is a shorthand for this function.
|
164
|
+
#
|
165
|
+
# argv = "It's better to give than to receive".shellescape
|
166
|
+
# argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
|
167
|
+
#
|
168
|
+
# # Search files in lib for method definitions
|
169
|
+
# pattern = "^[ \t]*def "
|
170
|
+
# open("| grep -Ern -e #{pattern.shellescape} lib") { |grep|
|
171
|
+
# grep.each_line { |line|
|
172
|
+
# file, lineno, matched_line = line.split(':', 3)
|
173
|
+
# # ...
|
174
|
+
# }
|
175
|
+
# }
|
176
|
+
#
|
177
|
+
# It is the caller's responsibility to encode the string in the right encoding
|
178
|
+
# for the shell environment where this string is used.
|
179
|
+
#
|
180
|
+
# Multibyte characters are treated as multibyte characters, not as bytes.
|
181
|
+
#
|
182
|
+
# Returns an empty quoted String if `str` has a length of zero.
|
183
|
+
#
|
184
|
+
def shellescape: (String str) -> String
|
185
|
+
|
186
|
+
# Builds a command line string from an argument list, `array`.
|
187
|
+
#
|
188
|
+
# All elements are joined into a single string with fields separated by a space,
|
189
|
+
# where each element is escaped for the Bourne shell and stringified using
|
190
|
+
# `to_s`.
|
191
|
+
#
|
192
|
+
# ary = ["There's", "a", "time", "and", "place", "for", "everything"]
|
193
|
+
# argv = Shellwords.join(ary)
|
194
|
+
# argv #=> "There\\'s a time and place for everything"
|
195
|
+
#
|
196
|
+
# Array#shelljoin is a shortcut for this function.
|
197
|
+
#
|
198
|
+
# ary = ["Don't", "rock", "the", "boat"]
|
199
|
+
# argv = ary.shelljoin
|
200
|
+
# argv #=> "Don\\'t rock the boat"
|
201
|
+
#
|
202
|
+
# You can also mix non-string objects in the elements as allowed in Array#join.
|
203
|
+
#
|
204
|
+
# output = `#{['ps', '-p', $$].shelljoin}`
|
205
|
+
#
|
206
|
+
def shelljoin: (Array[String] array) -> String
|
207
|
+
|
208
|
+
# Splits a string into an array of tokens in the same way the UNIX Bourne shell
|
209
|
+
# does.
|
210
|
+
#
|
211
|
+
# argv = Shellwords.split('here are "two words"')
|
212
|
+
# argv #=> ["here", "are", "two words"]
|
213
|
+
#
|
214
|
+
# Note, however, that this is not a command line parser. Shell metacharacters
|
215
|
+
# except for the single and double quotes and backslash are not treated as such.
|
216
|
+
#
|
217
|
+
# argv = Shellwords.split('ruby my_prog.rb | less')
|
218
|
+
# argv #=> ["ruby", "my_prog.rb", "|", "less"]
|
219
|
+
#
|
220
|
+
# String#shellsplit is a shortcut for this function.
|
221
|
+
#
|
222
|
+
# argv = 'here are "two words"'.shellsplit
|
223
|
+
# argv #=> ["here", "are", "two words"]
|
224
|
+
#
|
225
|
+
def shellsplit: (String line) -> Array[String]
|
226
|
+
|
227
|
+
alias shellwords shellsplit
|
228
|
+
end
|
229
|
+
|
230
|
+
class Array[unchecked out Elem]
|
231
|
+
# Builds a command line string from an argument list `array` joining all
|
232
|
+
# elements escaped for the Bourne shell and separated by a space.
|
233
|
+
#
|
234
|
+
# See Shellwords.shelljoin for details.
|
235
|
+
#
|
236
|
+
def shelljoin: () -> String
|
237
|
+
end
|
238
|
+
|
239
|
+
class String
|
240
|
+
# Escapes `str` so that it can be safely used in a Bourne shell command line.
|
241
|
+
#
|
242
|
+
# See Shellwords.shellescape for details.
|
243
|
+
#
|
244
|
+
def shellescape: () -> String
|
245
|
+
|
246
|
+
# Splits `str` into an array of tokens in the same way the UNIX Bourne shell
|
247
|
+
# does.
|
248
|
+
#
|
249
|
+
# See Shellwords.shellsplit for details.
|
250
|
+
#
|
251
|
+
def shellsplit: () -> Array[String]
|
252
|
+
end
|
@@ -0,0 +1,469 @@
|
|
1
|
+
class Addrinfo
|
2
|
+
# iterates over the list of Addrinfo objects obtained by Addrinfo.getaddrinfo.
|
3
|
+
#
|
4
|
+
# Addrinfo.foreach(nil, 80) {|x| p x }
|
5
|
+
# #=> #<Addrinfo: 127.0.0.1:80 TCP (:80)>
|
6
|
+
# # #<Addrinfo: 127.0.0.1:80 UDP (:80)>
|
7
|
+
# # #<Addrinfo: [::1]:80 TCP (:80)>
|
8
|
+
# # #<Addrinfo: [::1]:80 UDP (:80)>
|
9
|
+
#
|
10
|
+
def self.foreach: (String? nodename, String | Integer service, ?Integer? family, ?Symbol socktype, ?(Symbol | Integer) protocol, ?Integer flags, ?timeout: Numeric) { (Addrinfo) -> void } -> void
|
11
|
+
|(String? nodename, String | Integer service, ?Integer? family, ?Symbol socktype, ?(Symbol | Integer) protocol, ?Integer flags, ?timeout: Numeric) -> Enumerable[Addrinfo]
|
12
|
+
|
13
|
+
# returns a list of addrinfo objects as an array.
|
14
|
+
#
|
15
|
+
# This method converts nodename (hostname) and service (port) to addrinfo. Since
|
16
|
+
# the conversion is not unique, the result is a list of addrinfo objects.
|
17
|
+
#
|
18
|
+
# nodename or service can be nil if no conversion intended.
|
19
|
+
#
|
20
|
+
# family, socktype and protocol are hint for preferred protocol. If the result
|
21
|
+
# will be used for a socket with SOCK_STREAM, SOCK_STREAM should be specified as
|
22
|
+
# socktype. If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for
|
23
|
+
# SOCK_STREAM. If they are omitted or nil is given, the result is not
|
24
|
+
# restricted.
|
25
|
+
#
|
26
|
+
# Similarly, PF_INET6 as family restricts for IPv6.
|
27
|
+
#
|
28
|
+
# flags should be bitwise OR of Socket::AI_??? constants such as follows. Note
|
29
|
+
# that the exact list of the constants depends on OS.
|
30
|
+
#
|
31
|
+
# AI_PASSIVE Get address to use with bind()
|
32
|
+
# AI_CANONNAME Fill in the canonical name
|
33
|
+
# AI_NUMERICHOST Prevent host name resolution
|
34
|
+
# AI_NUMERICSERV Prevent service name resolution
|
35
|
+
# AI_V4MAPPED Accept IPv4-mapped IPv6 addresses
|
36
|
+
# AI_ALL Allow all addresses
|
37
|
+
# AI_ADDRCONFIG Accept only if any address is assigned
|
38
|
+
#
|
39
|
+
# Note that socktype should be specified whenever application knows the usage of
|
40
|
+
# the address. Some platform causes an error when socktype is omitted and
|
41
|
+
# servname is specified as an integer because some port numbers, 512 for
|
42
|
+
# example, are ambiguous without socktype.
|
43
|
+
#
|
44
|
+
# Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM)
|
45
|
+
# #=> [#<Addrinfo: 203.178.141.194:80 TCP (www.kame.net)>,
|
46
|
+
# # #<Addrinfo: [2001:200:dff:fff1:216:3eff:feb1:44d7]:80 TCP (www.kame.net)>]
|
47
|
+
#
|
48
|
+
def self.getaddrinfo: (String nodename, ?(String | Integer) service, ?Symbol? family, ?(Symbol | Integer) protocol) -> Array[Addrinfo]
|
49
|
+
|
50
|
+
# returns an addrinfo object for IP address.
|
51
|
+
#
|
52
|
+
# The port, socktype, protocol of the result is filled by zero. So, it is not
|
53
|
+
# appropriate to create a socket.
|
54
|
+
#
|
55
|
+
# Addrinfo.ip("localhost") #=> #<Addrinfo: 127.0.0.1 (localhost)>
|
56
|
+
#
|
57
|
+
def self.ip: (String host) -> Addrinfo
|
58
|
+
|
59
|
+
# returns an addrinfo object for TCP address.
|
60
|
+
#
|
61
|
+
# Addrinfo.tcp("localhost", "smtp") #=> #<Addrinfo: 127.0.0.1:25 TCP (localhost:smtp)>
|
62
|
+
#
|
63
|
+
def self.tcp: (String host, String | Integer service) -> Addrinfo
|
64
|
+
|
65
|
+
# returns an addrinfo object for UDP address.
|
66
|
+
#
|
67
|
+
# Addrinfo.udp("localhost", "daytime") #=> #<Addrinfo: 127.0.0.1:13 UDP (localhost:daytime)>
|
68
|
+
#
|
69
|
+
def self.udp: (String host, String | Integer service) -> Addrinfo
|
70
|
+
|
71
|
+
# returns an addrinfo object for UNIX socket address.
|
72
|
+
#
|
73
|
+
# *socktype* specifies the socket type. If it is omitted, :STREAM is used.
|
74
|
+
#
|
75
|
+
# Addrinfo.unix("/tmp/sock") #=> #<Addrinfo: /tmp/sock SOCK_STREAM>
|
76
|
+
# Addrinfo.unix("/tmp/sock", :DGRAM) #=> #<Addrinfo: /tmp/sock SOCK_DGRAM>
|
77
|
+
#
|
78
|
+
def self.unix: (String path, ?Symbol socktype) -> Addrinfo
|
79
|
+
|
80
|
+
public
|
81
|
+
|
82
|
+
# returns the address family as an integer.
|
83
|
+
#
|
84
|
+
# Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true
|
85
|
+
#
|
86
|
+
def afamily: () -> Integer
|
87
|
+
|
88
|
+
# creates a socket bound to self.
|
89
|
+
#
|
90
|
+
# If a block is given, it is called with the socket and the value of the block
|
91
|
+
# is returned. The socket is returned otherwise.
|
92
|
+
#
|
93
|
+
# Addrinfo.udp("0.0.0.0", 9981).bind {|s|
|
94
|
+
# s.local_address.connect {|s| s.send "hello", 0 }
|
95
|
+
# p s.recv(10) #=> "hello"
|
96
|
+
# }
|
97
|
+
#
|
98
|
+
def bind: () -> Socket
|
99
|
+
| () { (Socket) -> void } -> void
|
100
|
+
|
101
|
+
# returns the canonical name as a string.
|
102
|
+
#
|
103
|
+
# nil is returned if no canonical name.
|
104
|
+
#
|
105
|
+
# The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is
|
106
|
+
# specified.
|
107
|
+
#
|
108
|
+
# list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
|
109
|
+
# p list[0] #=> #<Addrinfo: 221.186.184.68:80 TCP carbon.ruby-lang.org (www.ruby-lang.org)>
|
110
|
+
# p list[0].canonname #=> "carbon.ruby-lang.org"
|
111
|
+
#
|
112
|
+
def canonname: () -> String
|
113
|
+
|
114
|
+
# creates a socket connected to the address of self.
|
115
|
+
#
|
116
|
+
# The optional argument *opts* is options represented by a hash. *opts* may have
|
117
|
+
# following options:
|
118
|
+
#
|
119
|
+
# :timeout
|
120
|
+
# : specify the timeout in seconds.
|
121
|
+
#
|
122
|
+
#
|
123
|
+
# If a block is given, it is called with the socket and the value of the block
|
124
|
+
# is returned. The socket is returned otherwise.
|
125
|
+
#
|
126
|
+
# Addrinfo.tcp("www.ruby-lang.org", 80).connect {|s|
|
127
|
+
# s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
|
128
|
+
# puts s.read
|
129
|
+
# }
|
130
|
+
#
|
131
|
+
def connect: (?timeout: Numeric) { (Socket) -> void } -> void
|
132
|
+
| (?timeout: Numeric) -> Socket
|
133
|
+
|
134
|
+
# creates a socket connected to the address of self.
|
135
|
+
#
|
136
|
+
# If one or more arguments given as *local_addr_args*, it is used as the local
|
137
|
+
# address of the socket. *local_addr_args* is given for family_addrinfo to
|
138
|
+
# obtain actual address.
|
139
|
+
#
|
140
|
+
# If *local_addr_args* is not given, the local address of the socket is not
|
141
|
+
# bound.
|
142
|
+
#
|
143
|
+
# The optional last argument *opts* is options represented by a hash. *opts* may
|
144
|
+
# have following options:
|
145
|
+
#
|
146
|
+
# :timeout
|
147
|
+
# : specify the timeout in seconds.
|
148
|
+
#
|
149
|
+
#
|
150
|
+
# If a block is given, it is called with the socket and the value of the block
|
151
|
+
# is returned. The socket is returned otherwise.
|
152
|
+
#
|
153
|
+
# Addrinfo.tcp("www.ruby-lang.org", 80).connect_from("0.0.0.0", 4649) {|s|
|
154
|
+
# s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
|
155
|
+
# puts s.read
|
156
|
+
# }
|
157
|
+
#
|
158
|
+
# # Addrinfo object can be taken for the argument.
|
159
|
+
# Addrinfo.tcp("www.ruby-lang.org", 80).connect_from(Addrinfo.tcp("0.0.0.0", 4649)) {|s|
|
160
|
+
# s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
|
161
|
+
# puts s.read
|
162
|
+
# }
|
163
|
+
#
|
164
|
+
def connect_from: (String host, Integer port, ?timeout: Numeric) { (Socket) -> void } -> void
|
165
|
+
| (String host, Integer port, ?timeout: Numeric) -> Socket
|
166
|
+
| (Addrinfo sockaddr, ?timeout: Numeric) { (Socket) -> void } -> void
|
167
|
+
| (Addrinfo sockaddr, ?timeout: Numeric) -> Socket
|
168
|
+
|
169
|
+
# creates a socket connected to *remote_addr_args* and bound to self.
|
170
|
+
#
|
171
|
+
# The optional last argument *opts* is options represented by a hash. *opts* may
|
172
|
+
# have following options:
|
173
|
+
#
|
174
|
+
# :timeout
|
175
|
+
# : specify the timeout in seconds.
|
176
|
+
#
|
177
|
+
#
|
178
|
+
# If a block is given, it is called with the socket and the value of the block
|
179
|
+
# is returned. The socket is returned otherwise.
|
180
|
+
#
|
181
|
+
# Addrinfo.tcp("0.0.0.0", 4649).connect_to("www.ruby-lang.org", 80) {|s|
|
182
|
+
# s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
|
183
|
+
# puts s.read
|
184
|
+
# }
|
185
|
+
#
|
186
|
+
def connect_to: (String host, Integer port, ?timeout: Numeric) { (Socket) -> void } -> void
|
187
|
+
| (String host, Integer port, ?timeout: Numeric) -> Socket
|
188
|
+
| (Addrinfo sockaddr, ?timeout: Numeric) { (Socket) -> void } -> void
|
189
|
+
| (Addrinfo sockaddr, ?timeout: Numeric) -> Socket
|
190
|
+
|
191
|
+
# creates an Addrinfo object from the arguments.
|
192
|
+
#
|
193
|
+
# The arguments are interpreted as similar to self.
|
194
|
+
#
|
195
|
+
# Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80)
|
196
|
+
# #=> #<Addrinfo: 221.186.184.68:80 TCP (www.ruby-lang.org:80)>
|
197
|
+
#
|
198
|
+
# Addrinfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2")
|
199
|
+
# #=> #<Addrinfo: /tmp/sock2 SOCK_STREAM>
|
200
|
+
#
|
201
|
+
def family_addrinfo: (String host, Integer port) -> Addrinfo
|
202
|
+
| (String path) -> Addrinfo
|
203
|
+
|
204
|
+
# returns nodename and service as a pair of strings. This converts struct
|
205
|
+
# sockaddr in addrinfo to textual representation.
|
206
|
+
#
|
207
|
+
# flags should be bitwise OR of Socket::NI_??? constants.
|
208
|
+
#
|
209
|
+
# Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"]
|
210
|
+
#
|
211
|
+
# Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV)
|
212
|
+
# #=> ["localhost", "80"]
|
213
|
+
#
|
214
|
+
def getnameinfo: (?Integer flags) -> [String, Integer]
|
215
|
+
|
216
|
+
# returns a string which shows addrinfo in human-readable form.
|
217
|
+
#
|
218
|
+
# Addrinfo.tcp("localhost", 80).inspect #=> "#<Addrinfo: 127.0.0.1:80 TCP (localhost)>"
|
219
|
+
# Addrinfo.unix("/tmp/sock").inspect #=> "#<Addrinfo: /tmp/sock SOCK_STREAM>"
|
220
|
+
#
|
221
|
+
def inspect: () -> String
|
222
|
+
|
223
|
+
# returns a string which shows the sockaddr in *addrinfo* with human-readable
|
224
|
+
# form.
|
225
|
+
#
|
226
|
+
# Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80"
|
227
|
+
# Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80"
|
228
|
+
# Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock"
|
229
|
+
#
|
230
|
+
def inspect_sockaddr: () -> String
|
231
|
+
|
232
|
+
# returns true if addrinfo is internet (IPv4/IPv6) address. returns false
|
233
|
+
# otherwise.
|
234
|
+
#
|
235
|
+
# Addrinfo.tcp("127.0.0.1", 80).ip? #=> true
|
236
|
+
# Addrinfo.tcp("::1", 80).ip? #=> true
|
237
|
+
# Addrinfo.unix("/tmp/sock").ip? #=> false
|
238
|
+
#
|
239
|
+
def ip?: () -> bool
|
240
|
+
|
241
|
+
# Returns the IP address as a string.
|
242
|
+
#
|
243
|
+
# Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1"
|
244
|
+
# Addrinfo.tcp("::1", 80).ip_address #=> "::1"
|
245
|
+
#
|
246
|
+
def ip_address: () -> String
|
247
|
+
|
248
|
+
# Returns the port number as an integer.
|
249
|
+
#
|
250
|
+
# Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80
|
251
|
+
# Addrinfo.tcp("::1", 80).ip_port #=> 80
|
252
|
+
#
|
253
|
+
def ip_port: () -> Integer
|
254
|
+
|
255
|
+
# Returns the IP address and port number as 2-element array.
|
256
|
+
#
|
257
|
+
# Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80]
|
258
|
+
# Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80]
|
259
|
+
#
|
260
|
+
def ip_unpack: () -> [String, Integer]
|
261
|
+
|
262
|
+
# returns true if addrinfo is IPv4 address. returns false otherwise.
|
263
|
+
#
|
264
|
+
# Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true
|
265
|
+
# Addrinfo.tcp("::1", 80).ipv4? #=> false
|
266
|
+
# Addrinfo.unix("/tmp/sock").ipv4? #=> false
|
267
|
+
#
|
268
|
+
def ipv4?: () -> bool
|
269
|
+
|
270
|
+
# Returns true for IPv4 loopback address (127.0.0.0/8). It returns false
|
271
|
+
# otherwise.
|
272
|
+
#
|
273
|
+
def ipv4_loopback?: () -> bool
|
274
|
+
|
275
|
+
# Returns true for IPv4 multicast address (224.0.0.0/4). It returns false
|
276
|
+
# otherwise.
|
277
|
+
#
|
278
|
+
def ipv4_multicast?: () -> bool
|
279
|
+
|
280
|
+
# Returns true for IPv4 private address (10.0.0.0/8, 172.16.0.0/12,
|
281
|
+
# 192.168.0.0/16). It returns false otherwise.
|
282
|
+
#
|
283
|
+
def ipv4_private?: () -> bool
|
284
|
+
|
285
|
+
# returns true if addrinfo is IPv6 address. returns false otherwise.
|
286
|
+
#
|
287
|
+
# Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false
|
288
|
+
# Addrinfo.tcp("::1", 80).ipv6? #=> true
|
289
|
+
# Addrinfo.unix("/tmp/sock").ipv6? #=> false
|
290
|
+
#
|
291
|
+
def ipv6?: () -> bool
|
292
|
+
|
293
|
+
# Returns true for IPv6 link local address (ff80::/10). It returns false
|
294
|
+
# otherwise.
|
295
|
+
#
|
296
|
+
def ipv6_linklocal?: () -> bool
|
297
|
+
|
298
|
+
# Returns true for IPv6 loopback address (::1). It returns false otherwise.
|
299
|
+
#
|
300
|
+
def ipv6_loopback?: () -> bool
|
301
|
+
|
302
|
+
# Returns true for IPv6 multicast global scope address. It returns false
|
303
|
+
# otherwise.
|
304
|
+
#
|
305
|
+
def ipv6_mc_global?: () -> bool
|
306
|
+
|
307
|
+
# Returns true for IPv6 multicast link-local scope address. It returns false
|
308
|
+
# otherwise.
|
309
|
+
#
|
310
|
+
def ipv6_mc_linklocal?: () -> bool
|
311
|
+
|
312
|
+
# Returns true for IPv6 multicast node-local scope address. It returns false
|
313
|
+
# otherwise.
|
314
|
+
#
|
315
|
+
def ipv6_mc_nodelocal?: () -> bool
|
316
|
+
|
317
|
+
# Returns true for IPv6 multicast organization-local scope address. It returns
|
318
|
+
# false otherwise.
|
319
|
+
#
|
320
|
+
def ipv6_mc_orglocal?: () -> bool
|
321
|
+
|
322
|
+
# Returns true for IPv6 multicast site-local scope address. It returns false
|
323
|
+
# otherwise.
|
324
|
+
#
|
325
|
+
def ipv6_mc_sitelocal?: () -> bool
|
326
|
+
|
327
|
+
# Returns true for IPv6 multicast address (ff00::/8). It returns false
|
328
|
+
# otherwise.
|
329
|
+
#
|
330
|
+
def ipv6_multicast?: () -> bool
|
331
|
+
|
332
|
+
# Returns true for IPv6 site local address (ffc0::/10). It returns false
|
333
|
+
# otherwise.
|
334
|
+
#
|
335
|
+
def ipv6_sitelocal?: () -> bool
|
336
|
+
|
337
|
+
# Returns IPv4 address of IPv4 mapped/compatible IPv6 address. It returns nil if
|
338
|
+
# `self` is not IPv4 mapped/compatible IPv6 address.
|
339
|
+
#
|
340
|
+
# Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
|
341
|
+
# Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
|
342
|
+
# Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil
|
343
|
+
# Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil
|
344
|
+
# Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil
|
345
|
+
#
|
346
|
+
def ipv6_to_ipv4: () -> Addrinfo?
|
347
|
+
|
348
|
+
# Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns
|
349
|
+
# false otherwise.
|
350
|
+
#
|
351
|
+
def ipv6_unique_local?: () -> bool
|
352
|
+
|
353
|
+
# Returns true for IPv6 unspecified address (::). It returns false otherwise.
|
354
|
+
#
|
355
|
+
def ipv6_unspecified?: () -> bool
|
356
|
+
|
357
|
+
# Returns true for IPv4-compatible IPv6 address (::/80). It returns false
|
358
|
+
# otherwise.
|
359
|
+
#
|
360
|
+
def ipv6_v4compat?: () -> bool
|
361
|
+
|
362
|
+
# Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80). It returns false
|
363
|
+
# otherwise.
|
364
|
+
#
|
365
|
+
def ipv6_v4mapped?: () -> bool
|
366
|
+
|
367
|
+
# creates a listening socket bound to self.
|
368
|
+
#
|
369
|
+
def listen: (Integer backlog) -> void
|
370
|
+
|
371
|
+
def marshal_dump: () -> String
|
372
|
+
|
373
|
+
def marshal_load: (String) -> instance
|
374
|
+
|
375
|
+
# returns the protocol family as an integer.
|
376
|
+
#
|
377
|
+
# Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true
|
378
|
+
#
|
379
|
+
def pfamily: () -> Integer
|
380
|
+
|
381
|
+
# returns the socket type as an integer.
|
382
|
+
#
|
383
|
+
# Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true
|
384
|
+
#
|
385
|
+
def protocol: () -> Integer
|
386
|
+
|
387
|
+
# returns the socket type as an integer.
|
388
|
+
#
|
389
|
+
# Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true
|
390
|
+
#
|
391
|
+
def socktype: () -> Integer
|
392
|
+
|
393
|
+
# returns the socket address as packed struct sockaddr string.
|
394
|
+
#
|
395
|
+
# Addrinfo.tcp("localhost", 80).to_sockaddr
|
396
|
+
# #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
|
397
|
+
#
|
398
|
+
def to_s: () -> String
|
399
|
+
|
400
|
+
# returns the socket address as packed struct sockaddr string.
|
401
|
+
#
|
402
|
+
# Addrinfo.tcp("localhost", 80).to_sockaddr
|
403
|
+
# #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
|
404
|
+
#
|
405
|
+
def to_sockaddr: () -> String
|
406
|
+
|
407
|
+
# returns true if addrinfo is UNIX address. returns false otherwise.
|
408
|
+
#
|
409
|
+
# Addrinfo.tcp("127.0.0.1", 80).unix? #=> false
|
410
|
+
# Addrinfo.tcp("::1", 80).unix? #=> false
|
411
|
+
# Addrinfo.unix("/tmp/sock").unix? #=> true
|
412
|
+
#
|
413
|
+
def unix?: () -> bool
|
414
|
+
|
415
|
+
# Returns the socket path as a string.
|
416
|
+
#
|
417
|
+
# Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
|
418
|
+
#
|
419
|
+
def unix_path: () -> String
|
420
|
+
|
421
|
+
private
|
422
|
+
|
423
|
+
# returns a new instance of Addrinfo. The instance contains sockaddr, family,
|
424
|
+
# socktype, protocol. sockaddr means struct sockaddr which can be used for
|
425
|
+
# connect(2), etc. family, socktype and protocol are integers which is used for
|
426
|
+
# arguments of socket(2).
|
427
|
+
#
|
428
|
+
# sockaddr is specified as an array or a string. The array should be compatible
|
429
|
+
# to the value of IPSocket#addr or UNIXSocket#addr. The string should be struct
|
430
|
+
# sockaddr as generated by Socket.sockaddr_in or Socket.unpack_sockaddr_un.
|
431
|
+
#
|
432
|
+
# sockaddr examples:
|
433
|
+
#
|
434
|
+
# "AF_INET", 46102, "localhost.localdomain", "127.0.0.1"
|
435
|
+
# :
|
436
|
+
#
|
437
|
+
# "AF_INET6", 42304, "ip6-localhost", "::1"
|
438
|
+
# :
|
439
|
+
#
|
440
|
+
# "AF_UNIX", "/tmp/sock"
|
441
|
+
# :
|
442
|
+
# * Socket.sockaddr_in("smtp", "2001:DB8::1")
|
443
|
+
# * Socket.sockaddr_in(80, "172.18.22.42")
|
444
|
+
# * Socket.sockaddr_in(80, "www.ruby-lang.org")
|
445
|
+
# * Socket.sockaddr_un("/tmp/sock")
|
446
|
+
#
|
447
|
+
#
|
448
|
+
# In an AF_INET/AF_INET6 sockaddr array, the 4th element, numeric IP address, is
|
449
|
+
# used to construct socket address in the Addrinfo instance. If the 3rd element,
|
450
|
+
# textual host name, is non-nil, it is also recorded but used only for
|
451
|
+
# Addrinfo#inspect.
|
452
|
+
#
|
453
|
+
# family is specified as an integer to specify the protocol family such as
|
454
|
+
# Socket::PF_INET. It can be a symbol or a string which is the constant name
|
455
|
+
# with or without PF_ prefix such as :INET, :INET6, :UNIX, "PF_INET", etc. If
|
456
|
+
# omitted, PF_UNSPEC is assumed.
|
457
|
+
#
|
458
|
+
# socktype is specified as an integer to specify the socket type such as
|
459
|
+
# Socket::SOCK_STREAM. It can be a symbol or a string which is the constant name
|
460
|
+
# with or without SOCK_ prefix such as :STREAM, :DGRAM, :RAW, "SOCK_STREAM",
|
461
|
+
# etc. If omitted, 0 is assumed.
|
462
|
+
#
|
463
|
+
# protocol is specified as an integer to specify the protocol such as
|
464
|
+
# Socket::IPPROTO_TCP. It must be an integer, unlike family and socktype. If
|
465
|
+
# omitted, 0 is assumed. Note that 0 is reasonable value for most protocols,
|
466
|
+
# except raw socket.
|
467
|
+
#
|
468
|
+
def initialize: (String sockaddr, ?Symbol family, ?(Symbol | Integer)? socktype, ?Integer? protocol) -> untyped
|
469
|
+
end
|