So I have two script one in vb and one in perl. My perl script is to get the information from a file and parse it into the datase and also open a socket connection to my vb script and forward the information to send out email and paging notification. Now i setup my perl script to run as a service and do the parsing automatically. But when i try to create the socket connection to my vb...sometime it would work right and then the service stop. Or sometime if i stop and start my vb script it would work the first file but for the second file it doesnt n cause the service to stop. I'm using WIN32-Daemon as my service.
foreach my $filename ( readdir( DIR ) ) { my $filepath = "$scan_dir\\$filename"; if ( $filename =~ /\.txt$/i ) { my ($variable)=Read_File( $scan_dir, $filename ); Scan_File($variables); my $status=Socket($variable,$sock); } else { # get rid id miscellanous files in this directory unlink "$scan_dir\\$filename" or print ERROR "can't unl +ink $scan_dir\\$filename $!"; } }
Now if i comment out the "my $status=Socket" it work perfectly. and it not commend out sometime the notifcation would work other it cause the service to stop. Any Idea on what might be causing the problem?
sub Socket { my ($variable, $sock)=@_; if ($alarmtype =~ "WARNING") { $alarmtype = "NOTIFICATION"; } elsif ($alarmtype =~ "HALT") { $alarmtype = "SHUTDOWN"; } my $msg= "$alarmtype\r\n$eqpid\r\n$eqpid-$chamber\r\nMW\r\nTriant +Parameter Out of Bound. \r\nTCOM:\r\nN\r\nAlarmType='$alarmtype' $sen +sor on recipe $recipe is out of bound. Signal_Level = $signal_level L +ower = $alarm_lower_limit Upper = $alarm_upper_limit Code = $code \r\ +nI\r\nSTOP\r\nPHOT\r\n"; sendToLog ("TCOM socket: $msg") ; $sock->send($msg ); return ("TRUE"); }
This is my socket sub

In reply to Socket Problem by phimtau123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.