#!/bin/perl use POE; use POE::Component::Server::TCP; use JSON::XS; use strict; my %data; $data{"0"}="hallo0"; $data{"1"}="hallo1"; TCPServer (\%data); POE::Kernel->run(); sub TCPServer { my %daten=%{$_[0]}; POE::Component::Server::TCP->new( Alias => "SERVER", Port => 11211, ClientInput => sub { my ($session, $heap, $input) = @_[SESSION, HEAP, ARG0]; #print "Session ", $session->ID(), " got input: $input\n"; #$heap->{client}->put($input); #my $rip0 = $heap->{remote_ip}; #my $rport = $heap->{remote_port}; #my $id = $session->ID(); #my $log = scalar localtime(time).": Send data to session $id, client: $rip0, clientport: $rport"; #$logbox->insert('end', $log); #$logbox->see('end'); if ($input eq "GETDATA") { my $JSONObject = JSON::XS->new->ascii->pretty->allow_nonref(); my $senddata=$JSONObject->encode(\%daten); $heap->{client}->put($senddata); } } ); } # %hash; # # Tabellenheader # ID: Zeilennummer 0 beschreibt Header # # $hash{0}="Status" | "Reserve" | "Reserve" | "Reserve" | "Reserve" | "Spaltenanzahl" | "Zeilenanzahl" | "Beschriftung" | "Spalte1" | "Spalte2" # # Status 0-7; 0 critical (RED); 4 warning (ORANGE); 7 good (GREEN) #