Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RT#77716: LDAP.pm: new option keepalive for new()

If given, set the socket's SO_KEEPALIVE option depending on the
boolean value of the option's value.
  • Loading branch information...
commit c9e2387cb81a4ced0a7922cecadda02ffba707cb 1 parent 95c0049
@marschap authored
Showing with 12 additions and 1 deletion.
  1. +4 −1 lib/Net/LDAP.pm
  2. +8 −0 lib/Net/LDAP.pod
View
5 lib/Net/LDAP.pm
@@ -5,7 +5,7 @@
package Net::LDAP;
use strict;
-use Socket qw(AF_INET AF_INET6 AF_UNSPEC);
+use Socket qw(AF_INET AF_INET6 AF_UNSPEC SOL_SOCKET SO_KEEPALIVE);
use IO::Socket;
use IO::Select;
use Tie::Hash;
@@ -119,6 +119,9 @@ sub new {
return undef unless $obj->{net_ldap_socket};
+ $obj->{net_ldap_socket}->setsockopt(SOL_SOCKET, SO_KEEPALIVE, $arg->{keepalive} ? 1 : 0)
+ if (defined($arg->{keepalive}));
+
$obj->{net_ldap_resp} = {};
$obj->{net_ldap_version} = $arg->{version} || $LDAP_VERSION;
$obj->{net_ldap_async} = $arg->{async} ? 1 : 0;
View
8 lib/Net/LDAP.pod
@@ -89,6 +89,14 @@ Port to connect to on the remote server. May be overridden by C<HOST>.
Connection scheme to use when not using an URI as C<HOST>.
(Default: ldap)
+=item keepalive =E<gt> 1
+
+If given, set the socket's SO_KEEPALIVE option depending on
+the boolean value of the option.
+(Default: use system default)
+
+Failures in changing the socket's SO_KEEPALIVE option are ignored.
+
=item timeout =E<gt> N
Timeout passed to L<IO::Socket> when connecting the remote server.
Please sign in to comment.
Something went wrong with that request. Please try again.