DBGp-Client

 view release on metacpan or  search on metacpan

lib/DBGp/Client/Listener.pm  view on Meta::CPAN

use DBGp::Client::Connection;

=head2 new

    my $listener = DBGp::Client::Listener->new(%opts);

Possible options are C<port> to specify a TCP port, and C<path> to
specify the path for an Unix-domain socket.

For Unix-domain socket, passing C<mode> performs an additional
C<chmod> call before starting to listen for connections.

=cut

sub new {
    my ($class, %args) = @_;
    my $self = bless {
        port    => $args{port},
        path    => $args{path},
        mode    => $args{mode},
        socket  => undef,

lib/DBGp/Client/Listener.pm  view on Meta::CPAN

        );
    } elsif ($self->{path}) {
        if (-S $self->{path}) {
            unlink $self->{path} or die "Unable to unlink stale socket: $!";
        }

        $self->{socket} = IO::Socket::UNIX->new(
            Local     => $self->{path},
        );
        if ($self->{socket} && defined $self->{mode}) {
            chmod $self->{mode}, $self->{path}
                or $self->{socket} = undef;
        }
        if ($self->{socket}) {
            $self->{socket}->listen(1)
                or $self->{socket} = undef;
        }
    }

    die "Unable to start listening: $!" unless $self->{socket};
}



( run in 0.276 second using v1.01-cache-2.11-cpan-496ff517765 )