Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Socket Problem

by phimtau123 (Novice)
on Jun 21, 2007 at 00:37 UTC ( [id://622428]=perlquestion: print w/replies, xml ) Need Help??

phimtau123 has asked for the wisdom of the Perl Monks concerning the following question:

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

Replies are listed 'Best First'.
Re: Socket Problem
by chrism01 (Friar) on Jun 21, 2007 at 01:42 UTC
    I think we'd like to see your socket code (ie where you create the client socket).
    Also, you aren't checking for an error
      my vb code
      If sockETH.State = sckConnected Then txbETHsocket.Text = " CONNECTED" Else txbETHsocket.Text = " OFF" If sockETH.State <> sckClosed Then sockETH.Close sockETH.LocalPort = "5555" 'ETH socket port. ParC +on parent needs to know this port, so he can talk to it. sockETH.Listen 'Start listening. His +events now can be triggered. End If
      sockETH.LocalPort = "5555" sockETH.Listen
      That to listen for the connection
      Private Sub sockETH_ConnectionRequest(ByVal requestID As Long) sockETH.Close 'Must clo +se it first before connecting. sockETH.Accept requestID 'Accept t +he connection.
      and i have another sub in vb to process the data....I mean everything work it just that the socket connection behavior is erratic. work one time then break

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://622428]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-20 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found