ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Socket.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Socket.pm (file contents):
Revision 1.102 by root, Thu Jul 30 16:39:19 2009 UTC vs.
Revision 1.103 by root, Fri Jul 31 20:16:29 2009 UTC

45 45
46use base 'Exporter'; 46use base 'Exporter';
47 47
48our @EXPORT = qw( 48our @EXPORT = qw(
49 getprotobyname 49 getprotobyname
50 parse_hostport 50 parse_hostport format_hostport
51 parse_ipv4 parse_ipv6 51 parse_ipv4 parse_ipv6
52 parse_ip parse_address 52 parse_ip parse_address
53 format_ipv4 format_ipv6 53 format_ipv4 format_ipv6
54 format_ip format_address 54 format_ip format_address
55 address_family 55 address_family
278 278
279 # hostnames must not contain :'s 279 # hostnames must not contain :'s
280 return if $host =~ /:/ && !parse_ipv6 $host; 280 return if $host =~ /:/ && !parse_ipv6 $host;
281 281
282 ($host, $port) 282 ($host, $port)
283}
284
285=item $string = format_hostport $host, $port
286
287Takes a host (in textual form) and a port and formats in unambigiously in
288a way that C<parse_hostport> can parse it again. C<$port> can be C<undef>.
289
290=cut
291
292sub format_hostport($;$) {
293 my ($host, $port) = @_;
294
295 $port = ":$port" if length $port;
296 $host = "[$host]" if $host =~ /:/;
297
298 "$host$port"
283} 299}
284 300
285=item $sa_family = address_family $ipn 301=item $sa_family = address_family $ipn
286 302
287Returns the address family/protocol-family (AF_xxx/PF_xxx, in one value :) 303Returns the address family/protocol-family (AF_xxx/PF_xxx, in one value :)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines