summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8769528)
raw | patch | inline | side by side (parent: 8769528)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 10 Jul 2008 14:54:38 +0000 (14:54 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 10 Jul 2008 14:54:38 +0000 (14:54 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11596 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index c9cbfa3ad914dc5e27d0e074e5dce46e4846f66b..b6d603042a055468665e565c493edd3b3c7f547e 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_ip, $gosa_port, $gosa_timeout,
$foreign_server_string, $server_domain, $ServerPackages_key, $foreign_servers_register_delay,
- $wake_on_lan_passwd,
+ $wake_on_lan_passwd, $job_synchronization, $modified_jobs_loop_delay,
);
# additional variable which should be globaly accessable
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
"plainname DEFAULT 'none'",
+ "siserver DEFAULT 'none'",
+ "modified DEFAULT '0'",
);
# holds all other gosa-si-server
"domain" => [\$server_domain, ""],
"key" => [\$ServerPackages_key, "none"],
"key-lifetime" => [\$foreign_servers_register_delay, 120],
+ "job-synchronization" => [\$job_synchronization, "true"],
+ "synchronization-loop" => [\$modified_jobs_loop_delay, 5],
}
);
if ($done) {
# if a job or a gosa message comes from a foreign server, fake module to GosaPackages
# so gosa-si-server knows how to process this kind of messages
- if ($header =~ /^gosa_/ || $header =~ /job_/) {
+ if ($header =~ /^gosa_/ || $header =~ /^job_/) {
$module = "GosaPackages";
}
$kernel->sig(USR2 => "recreate_packages_db");
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
$kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
}
+# if a job got an update or was modified anyway, send to all other si-server an update message
+# of this jobs
+sub watch_for_modified_jobs {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE ((siserver='localhost') AND (modified='1'))";
+ my $res = $job_db->select_dbentry( $sql_statement );
+
+ # if db contains no jobs which should be update, do nothing
+ if (keys %$res != 0) {
+
+ # make out of the db result a gosa-si message
+ my $update_msg = &db_res2si_msg ($res, "foreign_job_updates", "KNOWN_SERVER", "MY_LOCAL_ADDRESS");
+
+ # determine all other si-server a foreign_job_updates message should be send
+ my $sql_statement= "SELECT * FROM $known_server_tn";
+ my $res = $known_server_db->select_dbentry( $sql_statement );
+ while( my ($hit_num, $hit) = each %$res ) {
+ my $act_update_msg = $update_msg;
+ my $act_target_address = $hit->{hostname};
+ my $act_target_key = $hit->{hostkey};
+ my ($act_target_ip, $act_target_port) = split(/:/, $act_target_address);
+ my $act_source_address = &get_local_ip_for_remote_ip($act_target_ip).":$act_target_port";
+
+ $act_update_msg =~ s/<target>KNOWN_SERVER<\/target>/<target>$act_target_address<\/target>/g;
+ $act_update_msg =~ s/<source>MY_LOCAL_ADDRESS<\/source>/<source>$act_source_address<\/source>/g;
+ &send_msg_to_target($act_update_msg, $act_target_address, $act_target_key, "foreign_job_updates" , "J");
+ }
+
+ # set jobs all jobs to modified = 0, wait until the next modification for updates of other si-server
+ $sql_statement = "UPDATE $job_queue_tn SET modified='0' ";
+ $res = $job_db->update_dbentry($sql_statement);
+ }
+
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
+}
+
+
sub watch_for_new_jobs {
if($watch_for_new_jobs_in_progress == 0) {
$watch_for_new_jobs_in_progress = 1;
my ($kernel,$heap) = @_[KERNEL, HEAP];
- # check gosa job queue for jobs with executable timestamp
+ # check gosa job quaeue for jobs with executable timestamp
my $timestamp = &get_time();
my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
my $res = $job_db->exec_statement( $sql_statement );
}
+
sub watch_for_new_messages {
my ($kernel,$heap) = @_[KERNEL, HEAP];
my @coll_user_msg; # collection list of outgoing messages
watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
+ watch_for_modified_jobs => \&watch_for_modified_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
watch_for_old_known_clients => \&watch_for_old_known_clients,
create_packages_list_db => \&run_create_packages_list_db,
index 5587dd218d899a0efbb5bcea7ae0abe6c903aeea..686846d85d3dbc5687305cf5186394fb777580e9 100644 (file)
if( inet_aton($gosa_ip) ){ $gosa_ip = inet_ntoa(inet_aton($gosa_ip)); }
$main::gosa_address = "$gosa_ip:$gosa_port";
-# create general settings for this module
-#y $gosa_cipher = &create_ciphering($gosa_passwd);
my $xml = new XML::Simple();
# import local events
}
}
-# moved to GosaSupportDaemon: 03-06-2008: rettenbe
-#=== FUNCTION ================================================================
-# NAME: get_interface_for_ip
-# PARAMETERS: ip address (i.e. 192.168.0.1)
-# RETURNS: array: list of interfaces if ip=0.0.0.0, matching interface if found, undef else
-# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
-#===============================================================================
-#sub get_interface_for_ip {
-# my $result;
-# my $ip= shift;
-# if ($ip && length($ip) > 0) {
-# my @ifs= &get_interfaces();
-# if($ip eq "0.0.0.0") {
-# $result = "all";
-# } else {
-# foreach (@ifs) {
-# my $if=$_;
-# if(get_ip($if) eq $ip) {
-# $result = $if;
-# }
-# }
-# }
-# }
-# return $result;
-#}
-
-# moved to GosaSupportDaemon: 03-06-2008: rettenbe
-#=== FUNCTION ================================================================
-# NAME: get_interfaces
-# PARAMETERS: none
-# RETURNS: (list of interfaces)
-# DESCRIPTION: Uses proc fs (/proc/net/dev) to get list of interfaces.
-#===============================================================================
-#sub get_interfaces {
-# my @result;
-# my $PROC_NET_DEV= ('/proc/net/dev');
-#
-# open(PROC_NET_DEV, "<$PROC_NET_DEV")
-# or die "Could not open $PROC_NET_DEV";
-#
-# my @ifs = <PROC_NET_DEV>;
-#
-# close(PROC_NET_DEV);
-#
-# # Eat first two line
-# shift @ifs;
-# shift @ifs;
-#
-# chomp @ifs;
-# foreach my $line(@ifs) {
-# my $if= (split /:/, $line)[0];
-# $if =~ s/^\s+//;
-# push @result, $if;
-# }
-#
-# return @result;
-#}
#=== FUNCTION ================================================================
# NAME: get_mac
return $result;
}
-# moved to GosaSupportDaemon: 03-06-2008: rettenbe
-#=== FUNCTION ================================================================
-# NAME: get_ip
-# PARAMETERS: interface name (i.e. eth0)
-# RETURNS: (ip address)
-# DESCRIPTION: Uses ioctl to get ip address directly from system.
-#===============================================================================
-#sub get_ip {
-# my $ifreq= shift;
-# my $result= "";
-# my $SIOCGIFADDR= 0x8915; # man 2 ioctl_list
-# my $proto= getprotobyname('ip');
-#
-# socket SOCKET, PF_INET, SOCK_DGRAM, $proto
-# or die "socket: $!";
-#
-# if(ioctl SOCKET, $SIOCGIFADDR, $ifreq) {
-# my ($if, $sin) = unpack 'a16 a16', $ifreq;
-# my ($port, $addr) = sockaddr_in $sin;
-# my $ip = inet_ntoa $addr;
-#
-# if ($ip && length($ip) > 0) {
-# $result = $ip;
-# }
-# }
-#
-# return $result;
-#}
-
#=== FUNCTION ================================================================
# NAME: process_incoming_msg
xmlmessage=>$msg,
macaddress=>$macaddress,
plainname=>$plain_name,
+ siserver=>"localhost",
+ modified=>"0",
};
my $res = $main::job_db->add_dbentry($func_dic);
if (not $res == 0) {
index 45492912e654135ce7ef8d7a060220bf5bc10bf7..8d165d92354a5b5b3cbddda58e4702ab8ccce4ec 100644 (file)
# if message is being forwarded from another server, strip of header prefixes
- $header =~ s/^gosa_|job_//;
+ $header =~ s/^gosa_|^job_//;
$msg =~ s/<header>gosa_(\w+)<\/header>|<header>job_(\w+)<\/header>/<header>$1<\/header>/;
index ad665646a2ef9a9a09b418553cc6f3ddcb7f257b..5ca8590146640ce38f4633afd63df61399b0954e 100644 (file)
sub GOTOACTIVATION {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
$header =~ s/CLMSG_//g;
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', progress='goto-activation' ".
+ "SET status='processing', progress='goto-activation', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
sub PROGRESS {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
$header =~ s/CLMSG_//g;
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET progress='$content' ".
+ "SET progress='$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
sub FAIREBOOT {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
$header =~ s/CLMSG_//g;
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content' ".
+ "SET status='processing', result='$header "."$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
sub TASKSKIP {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
$header =~ s/CLMSG_//g;
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content' ".
+ "SET status='processing', result='$header "."$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
sub TASKBEGIN {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
|| ($content eq 'savelog')
) {
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='done', result='$header "."$content' ".
+ "SET status='done', result='$header "."$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
# there is exactly one job entry in queue for this host
if (keys(%$res) == 1) {
&main::daemon_log("$session_id DEBUG: there is already one processing job in queue for host '$macaddress', run an update for this entry", 7);
- my $sql_statement = "UPDATE $main::job_queue_tn SET result='$header $content' WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET result='$header $content', modified='1' ".
+ "WHERE status='processing' AND macaddress LIKE '$macaddress'";
my $err = $main::job_db->update_dbentry($sql_statement);
if (not defined $err) {
&main::daemon_log("$session_id ERROR: cannot update job_db entry: ".Dumper($err), 1);
result=>"$header $content",
progress=>'none',
headertag=>'trigger_action_reinstall',
- targettag=>$source,
+ targettag=>$target,
xmlmessage=>'none',
macaddress=>$macaddress,
plainname=>$plain_name,
+ modified=>'1',
+ siserver=>$source,
};
my ($err, $error_str) = $main::job_db->add_dbentry($func_dic);
if ($err != 0) {
sub TASKEND {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# test whether content is an empty hash or a string which is required
$header =~ s/CLMSG_//g;
if ($content eq "savelog 0") {
- &main::daemon_log("$session_id DEBUG: got savelog from host '$source' - jub done", 7);
+ &main::daemon_log("$session_id DEBUG: got savelog from host '$target' - job done", 7);
my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->del_dbentry($sql_statement);
} else {
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content' ".
+ "SET status='processing', result='$header "."$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
sub TASKERROR {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# clean up header
&main::change_fai_state('error', \@{$msg_hash->{'macaddress'}}, $session_id);
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content' ".
+ "SET status='processing', result='$header "."$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
sub HOOK {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
- my $source = @{$msg_hash->{'target'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
my $macaddress = @{$msg_hash->{'macaddress'}}[0];
# clean up header
if(not ref($content) eq "STRING") { $content = ""; }
my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content' ".
+ "SET status='processing', result='$header "."$content', modified='1' ".
"WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->update_dbentry($sql_statement);
diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm
index e980dbad894755abf0a97fa429a00e5977521618..686d9f7687b09a54f9f69edfd2688545196948d9 100644 (file)
'confirm_new_server',
'new_foreign_client',
'trigger_wake',
+ 'foreign_job_updates',
);
@EXPORT = @events;
}
+sub foreign_job_updates {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+
+ my @act_keys = keys %$msg_hash;
+ my @jobs;
+ foreach my $key (@act_keys) {
+ if ($key =~ /answer\d+/ ) { push(@jobs, $key); }
+ }
+
+ foreach my $foreign_job (@jobs) {
+
+ # add job to job queue
+ my $func_dic = {table=>$main::job_queue_tn,
+ primkey=>['macaddress', 'headertag'],
+ timestamp=>@{@{$msg_hash->{$foreign_job}}[0]->{'timestamp'}}[0],
+ status=>@{@{$msg_hash->{$foreign_job}}[0]->{'status'}}[0],
+ result=>@{@{$msg_hash->{$foreign_job}}[0]->{'result'}}[0],
+ progress=>@{@{$msg_hash->{$foreign_job}}[0]->{'progress'}}[0],
+ headertag=>@{@{$msg_hash->{$foreign_job}}[0]->{'headertag'}}[0],
+ targettag=>@{@{$msg_hash->{$foreign_job}}[0]->{'targettag'}}[0],
+ xmlmessage=>@{@{$msg_hash->{$foreign_job}}[0]->{'xmlmessage'}}[0],
+ macaddress=>@{@{$msg_hash->{$foreign_job}}[0]->{'macaddress'}}[0],
+ plainname=>@{@{$msg_hash->{$foreign_job}}[0]->{'plainname'}}[0],
+ siserver=>$source,
+ modified=>"0",
+ };
+ my $res = $main::job_db->add_dbentry($func_dic);
+ if (not $res == 0) {
+ &main::daemon_log("$session_id ERROR: ServerPackages: process_job_msg: $res", 1);
+ } else {
+ &main::daemon_log("$session_id INFO: ServerPackages: $header, job '".@{@{$msg_hash->{$foreign_job}}[0]->{'headertag'}}[0].
+ "' successfully added to job queue", 5);
+ }
+ }
+
+ return;
+}
+
+
sub new_server {
my ($msg, $msg_hash, $session_id) = @_ ;
my $header = @{$msg_hash->{'header'}}[0];
index 41051e16ec3fe9de25cd530b79fc5bece421f0e6..7620f5885abe913813b81e7f626402560b0a82fa 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
# jobdb add
#$data = "<xml> <header>gosa_network_completition</header> <source>GOSA</source><target>GOSA</target><hostname>ws-muc-2</hostname></xml>";
#$data = "<xml> <header>job_sayHello</header> <source>10.89.1.155:20083</source><target>00:01:6c:9d:b9:fa</target><mac>00:1B:77:04:8A:6C</mac> <timestamp>20130102133908</timestamp> </xml>";
- #$data = "<xml> <header>job_ping</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>19700101000000</timestamp> </xml>";
-
+ $data = "<xml> <header>job_ping2</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>20130101000000</timestamp> </xml>";
+
# jobdb delete
#$data = "<xml> <header>gosa_delete_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase><id>3</id></phrase></clause></where></xml>";
# jobdb update
#$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase> <id>1</id></phrase></clause></where> <update><timestamp>19700101000000</timestamp></update></xml>";
- #$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source><target>GOSA</target><where><clause><phrase> <macaddress>00:01:6c:9d:b9:fa</macaddress></phrase></clause> </where> <update><status>processing</status> <result>update</result></update></xml>";
+ $data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source><target>GOSA</target><where><clause><phrase> <macaddress>00:01:6c:9d:b9:fa</macaddress></phrase></clause> </where> <update><status>processing</status> <result>update</result></update></xml>";
# jobdb query
#$data = "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><connector>and</connector><phrase><operator>gt</operator><ROWID>0</ROWID></phrase><phrase><operator>le</operator><ROWID>5</ROWID></phrase></clause></where></xml>";
#$data = "<xml><header>gosa_query_fai_server</header><source>GOSA</source> <target>10.89.1.131:20081</target></xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:aa:16</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fb</target> <source>GOSA</source> </xml>";
- $data = "<xml> <header>gosa_get_dak_keyring</header> <target>GOSA</target> <source>GOSA</source> </xml>";
+ #$data = "<xml> <header>gosa_get_dak_keyring</header> <target>GOSA</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>job_ping</header> <source>GOSA</source> <target>00:0c:29:02:e5:4d</target> <macaddress>00:0c:29:02:e5:4d</macaddress><timestamp>29700101000000</timestamp> </xml>";
- $data = "<xml> <header>gosa_network_completition</header> <source>GOSA</source> <target>GOSA</target> <hostname>localhost</hostname> </xml>";
+ #$data = "<xml> <header>gosa_network_completition</header> <source>GOSA</source> <target>GOSA</target> <hostname>localhost</hostname> </xml>";
$sock->write($data);
$answer = "nothing";