P2P::pDonkey::Util - Utility functions for P2P::pDonkey extensions.


P2P-pDonkey documentation Contained in the P2P-pDonkey distribution.

Index


Code Index:

NAME

Top

P2P::pDonkey::Util - Utility functions for P2P::pDonkey extensions.

SYNOPSIS

Top

  use P2P::pDonkey::Util ':all';
  print ip2addr(addr2ip('176.16.5.33')), "\n";

DESCRIPTION

Top

addr2ip HOSTNAME
    Analog for inet_aton, but returns unpacked ip number.

ip2addr IP_NUMBER
    Analog inet_ntoa, take as argument unpacked ip number.

EXPORT

None by default.

AUTHOR

Top

Alexey Klimkin, <klimkin@mail.ru>

SEE ALSO

Top

perl, Socket.


P2P-pDonkey documentation Contained in the P2P-pDonkey distribution.

# P2P::pDonkey::Util.pm
#
# Copyright (c) 2003-2004 Alexey klimkin <klimkin at cpan.org>. 
# All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
package P2P::pDonkey::Util;

use 5.006;
use strict;
use warnings;

require Exporter;

our $VERSION = '0.05';

our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
    addr2ip ip2addr 
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our @EXPORT = qw(
	
);

# Preloaded methods go here.

use Socket qw (inet_aton inet_ntoa);

sub addr2ip {
    my $ip;
    $ip = inet_aton($_[0]);
    defined $ip || return 0;
    return unpack('L', $ip);
}

sub ip2addr {
    return inet_ntoa(pack('L', $_[0]));
}

1;
__END__