Skip Menu |

This queue is for tickets about the PlRPC CPAN distribution.

Report information
The Basics
Id: 30378
Status: new
Priority: 0/
Queue: PlRPC

People
Owner: Nobody in particular
Requestors: viper.xz [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Error checking prevents custom socket
Since RPC::PlClient does not support UNIX Sockets I have tried to pass the socket like so: my $socket = IO::Socket::UNIX->new('/path/to/socket/file'); my $client RPC::PlClient->new( socket => $socket, ...other.options...); However the line: $self->Debug("Connected to %s, port %s", $socket->peerhost(), $socket->peerport()); Prevents this from working as IO::Socket::UNIX does not support the methods peerhost or peerport. This can be fixed by replacing it with: if ($socket->can('peerhost') && $socket->can('peerport')){ $self->Debug("Connected to %s, port %s", $socket->peerhost(), $socket->peerport()); } elsif ($socket->can('peerpath')){ $self->Debug("Connected to %s", $socket->peerpath()); } As well as this, you might want to consider adding support for creation of a UNIX Socket client within the `new` method. e.g: my $socket; if (!($socket = $self->{'socket'})) { if ($self->{'socket_file'}){ $socket = $self->{'socket'} = IO::Socket::UNIX->new($self-> {'socket_file'}); } else { $self->Fatal("Missing peer address") unless $self-> {'peeraddr'}; $self->Fatal("Missing peer port") unless ($self->{'peerport'} || index($self->{'peeraddr'}, ':') != -1); $socket = $self->{'socket'} = IO::Socket::INET->new ('PeerAddr' => $self->{'peeraddr'}, 'PeerPort' => $self->{'peerport'}, 'Proto' => $self->{'socket_proto'}, 'Type' => $self->{'socket_type'}, 'Timeout' => $self->{'timeout'}); $self->Fatal("Cannot connect: $!") unless $socket; } } if ($socket->can('peerhost') && $socket->can('peerport')){ $self->Debug("Connected to %s, port %s", $socket->peerhost(), $socket->peerport()); } elsif ($socket->can('peerpath')){ $self->Debug("Connected to %s", $socket->peerpath()); } ------------------------------- Finally, please note the following bug within Net::Daemon which may cause errors when connecting to a server. If connecting you recieve the error with your client: `Error while reading socket: Connection reset by peer.` And in your server log you have the line: `Child died: IN_ADDR_ANY is not a valid Socket macro` Simply remove the clients => ... from your call to PlServer->new(), (this is redundant if you are using unix file sockets anyway). James Austin
From: viper.xz [...] gmail.com
Added code as attachment to preserve whitespace.
my $socket; if (!($socket = $self->{'socket'})) { if ($self->{'socket_file'}){ $socket = $self->{'socket'} = IO::Socket::UNIX->new($self->{'socket_file'}); } else { $self->Fatal("Missing peer address") unless $self->{'peeraddr'}; $self->Fatal("Missing peer port") unless ($self->{'peerport'} || index($self->{'peeraddr'}, ':') != -1); $socket = $self->{'socket'} = IO::Socket::INET->new ('PeerAddr' => $self->{'peeraddr'}, 'PeerPort' => $self->{'peerport'}, 'Proto' => $self->{'socket_proto'}, 'Type' => $self->{'socket_type'}, 'Timeout' => $self->{'timeout'}); $self->Fatal("Cannot connect: $!") unless $socket; } } if ($socket->can('peerhost') && $socket->can('peerport')){ $self->Debug("Connected to %s, port %s", $socket->peerhost(), $socket->peerport()); } elsif ($socket->can('peerpath')){ $self->Debug("Connected to %s", $socket->peerpath()); }
From: viper.xz [...] gmail.com
Sorry, found one small error in that code, $self->Fatal("Cannot connect: $!") unless $socket; Should be moved to outside the if ($self->{'socket_file'}){} statement. i.e. Change from: if ($self->{'socket_file'}){ ... } else { ... $self->Fatal("Cannot connect: $!") unless $socket; } To: if ($self->{'socket_file'}){ ... } else { ... } $self->Fatal("Cannot connect: $!") unless $socket;