Hi all,

I've got a challenge outside my comfort zone (UDP Sockets). 

I'm trying to implement a UDP data aggregation process model that allows
reporting by autonomic, magnetic sensors <using less connectivity overhead>
as some reporting magnetic sensors have a low (crappy) bandwidth capability
(read Dial-Up or Crystal Ball Comms!).

I'm writing a UDP 'Client' that signals a UDP 'Server' when I (The Client)
am alive and ready to ingest global, magnetic sensor data. The Challenge is,
the UDP server requires the following connection criteria:

  1. Upon connect, I (client) send an initial "HELO Packet" in pipe
delimited format <below> as directed by the server to announce my presence.

  2. Every 60 seconds, the 'Server' Sends an "Is Client Alive?" packet
(IsAlive packet payload begins with ^4)... I (the client) need to respond
with a packet beginning with ^21 (I'm still here) packet beginning with ^21.


The Challenge:

I am trying to simulate network outages of up to 300 seconds <Using VMWARE
Client for Testing as that's all I've got> as this is the MAX AVG (that I've
calculated from various, historic... IO conn outages)... 

... However the UDP 'Client' Below that I largely modeled from "Perl
Cookbook => Chapt 17.4" seems to hang and it will not recover despite my
best interpretations of the process model [$SIG{ALRM}]. I've tried wrapping
the read using select as well but the system (OS) doesn't seem to recover. 


Read("you're not catching us at our best" - Jim Kirk, Trek IV).


The Potential Solution: I am trying to develop a UDP 'Client' that can
withstand a network outage of up to 300 seconds... then re-connect by
sending a new, initial "HELO Packet" and resuming the aggregation of many
magsensor site data.

The current script seems to hang (infinitively) without dumping to the
&sleep_wait sub, [time-waster].

Thanks for any insight... as I am really aggravated with this UDP thing
(thinking about going back to TCP but realize UDP is best for low bandwidth
clients)... This is a nano-version of the real app, way condensed due to
complexity (and my crappy programming skills) ]

PS: I'd love to spank the "powershell" weenies in the "scripting games", but
I've not been presented with a relevant challenge yet (provided it doesn't
include UDP Stuff!) 


--start-snip--
use IO::Socket;
use strict;

my ($initialmsg, $MSG, $sock, $server_host, $port, $ipaddr, $hishost,
$MAXLEN, $PORTNO, $TIMEOUT);

$server_host = "192.168.10.77"; # cant publicly display actual IP for this
problem, yes I realize this stinks... 
$PORTNO = "5001";
$MAXLEN = 1024;
$TIMEOUT = 5;
$initialmsg = "1|GEOMAGROUTER|datafetcher|22";
  
$sock = IO::Socket::INET->new(
    
    Proto => 'udp',
    PeerPort => $PORTNO,
    PeerAddr => $server_host) or die "Couldnt Create Initial Socket!! \n";

    # Send Initial HELO mesg
    $sock->send($initialmsg) or die "INITIALMSG Send Failed... $!";

   while(1) {
     
            eval {
             $SIG{ALRM} = sub { die "Alarm Called on TIMEOUT \n"};
             alarm $TIMEOUT;
             $sock->recv($MSG, $MAXLEN) or die "Oddball REC ERR $! \n";
             alarm 0;
             1;
           } or &sleep_wait;
            
                ($port, $ipaddr) = sockaddr_in($sock->peername);
                $hishost = gethostbyaddr($ipaddr, AF_INET);
                print "Server $hishost responded by sending: $MSG \n";
   }


sub sleep_wait {
    
     print "Comms Appear To be Down... will try reseting comms...\n";
   
   my $xctr;
   my $rslt;
   
   for (1...10) {
        $xctr++;
        $rslt = $xctr - 10 ;
        print "Comms Outage... Trying Again in $rslt seconds \n";
        sleep (1);
    }
}
--end-of-snip--



-BigAL

[EMAIL PROTECTED] 
[EMAIL PROTECTED] 

http://www.terramagnetoscope.net {magnetic research is the way to the
future!}
http://www.mollensoft.com {private home of my 'serious' apps}
























 



_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to