/[virtual-ldap]/bin/ldap-koha.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/ldap-koha.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (show annotations)
Fri May 20 12:00:03 2011 UTC (12 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 824 byte(s)
use SO_KEEPALIVE to detect hanging connections
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use IO::Select;
7 use IO::Socket;
8 use lib 'lib';
9 use LDAP::Koha;
10
11 my $listen = shift @ARGV || 'localhost:2389';
12
13 my $sock = IO::Socket::INET->new(
14 Listen => 5,
15 Proto => 'tcp',
16 Reuse => 1,
17 LocalAddr => $listen,
18 ) || die "can't listen to $listen $!";
19
20 warn "# listening on $listen";
21
22 my $sel = IO::Select->new($sock);
23 my %Handlers;
24 while (my @ready = $sel->can_read) {
25 foreach my $fh (@ready) {
26 if ($fh == $sock) {
27 # let's create a new socket
28 my $psock = $sock->accept;
29 $psock->sockopt(SO_KEEPALIVE,1);
30 $sel->add($psock);
31 $Handlers{*$psock} = LDAP::Koha->new($psock);
32 } else {
33 my $result = $Handlers{*$fh}->handle;
34 if ($result) {
35 # we have finished with the socket
36 $sel->remove($fh);
37 $fh->close;
38 delete $Handlers{*$fh};
39 }
40 }
41 }
42 }
43
44 1;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26