6 Einträge, 1 Seite |
1
2
3
4
5
#! perl -w
use strict;
use ServerController;
my $sc = ServerController->new(); #Referenz auf Objekt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package ServerController;
use strict;
use IO::Socket;
use threads;
use threads::shared
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
$self->{LISTENSOCKET} = IO::Socket::INET->new(...);
$self->{CLIENTS} = [];
$self->{THREAD} = threads->new("listen", $self);
return $self;
}
sub listen{
my $self = shift;
while(1){
my $client = $self->{LISTENSOCKET}->accept();
push @{$self->{CLIENTS}}, $client;
}
}
1;
my $self : shared = {};
Quotebless is not supported on shared references. In the current version, bless will only bless the thread local reference and the blessing will not propagate to the other threads. This is expected to be implemented in a future version of Perl.
6 Einträge, 1 Seite |