… | |
… | |
154 | |
154 | |
155 | If the C<$text> is C<unix/>, then this function returns a special token |
155 | If the C<$text> is C<unix/>, then this function returns a special token |
156 | recognised by the other functions in this module to mean "UNIX domain |
156 | recognised by the other functions in this module to mean "UNIX domain |
157 | socket". |
157 | socket". |
158 | |
158 | |
|
|
159 | =item $text = AnyEvent::Socket::aton $ipn |
|
|
160 | |
|
|
161 | Same as C<parse_address>, but not exported (think C<Socket::inet_aton> but |
|
|
162 | I<without> name resolution). |
|
|
163 | |
159 | =cut |
164 | =cut |
160 | |
165 | |
161 | sub parse_address($) { |
166 | sub parse_address($) { |
162 | &parse_ipv4 || &parse_ipv6 || &parse_unix |
167 | &parse_ipv4 || &parse_ipv6 || &parse_unix |
163 | } |
168 | } |
164 | |
169 | |
165 | *parse_ip =\&parse_address; #d# |
170 | *aton = \&parse_address; |
166 | |
171 | |
167 | =item ($host, $service) = parse_hostport $string[, $default_service] |
172 | =item ($host, $service) = parse_hostport $string[, $default_service] |
168 | |
173 | |
169 | Splitting a string of the form C<hostname:port> is a common |
174 | Splitting a string of the form C<hostname:port> is a common |
170 | problem. Unfortunately, just splitting on the colon makes it hard to |
175 | problem. Unfortunately, just splitting on the colon makes it hard to |
… | |
… | |
265 | |
270 | |
266 | This function works similarly to C<inet_ntop AF_INET || AF_INET6, ...>, |
271 | This function works similarly to C<inet_ntop AF_INET || AF_INET6, ...>, |
267 | except it automatically detects the address type. |
272 | except it automatically detects the address type. |
268 | |
273 | |
269 | Returns C<undef> if it cannot detect the type. |
274 | Returns C<undef> if it cannot detect the type. |
|
|
275 | |
|
|
276 | =item $text = AnyEvent::Socket::ntoa $ipn |
|
|
277 | |
|
|
278 | Same as format_address, but not exported (think C<inet_ntoa>). |
270 | |
279 | |
271 | =cut |
280 | =cut |
272 | |
281 | |
273 | sub format_address; |
282 | sub format_address; |
274 | sub format_address($) { |
283 | sub format_address($) { |
… | |
… | |
308 | } else { |
317 | } else { |
309 | return undef |
318 | return undef |
310 | } |
319 | } |
311 | } |
320 | } |
312 | |
321 | |
313 | *format_ip = \&format_address; |
322 | *ntoa = \&format_address; |
314 | |
323 | |
315 | =item inet_aton $name_or_address, $cb->(@addresses) |
324 | =item inet_aton $name_or_address, $cb->(@addresses) |
316 | |
325 | |
317 | Works similarly to its Socket counterpart, except that it uses a |
326 | Works similarly to its Socket counterpart, except that it uses a |
318 | callback. Also, if a host has only an IPv6 address, this might be passed |
327 | callback. Also, if a host has only an IPv6 address, this might be passed |