$server = IO::Socket::INET->new( Listen => 5, LocalPort => 1111, Proto => 'tcp', Reuse => 1, Type => SOCK_STREAM ) or die "Can't create server socket: $!"; while ($client = $server->accept()) { $receivefile = $receivepath . $timestamp . ".ord"; $client->autoflush(1); open FILE, $receivefile or die "Can't open: $!"; while (<$client>) { if (substr($_,0,4) ne $trnh && substr($_,0,4) ne $ordh && substr($ +_,0,4) ne $ordl && substr($_,0,4) ne $endt && substr($_,0,4) ne $trlr +) { $sizereceived = substr($_,0,5); print FILE substr($_,5); } else { print FILE $_; } $client->autoflush(1); sleep(1); } #End While Receiving from Client close FILE; check_size(); #If the filesize sent doesn't match #the filesize received, send an error #email. !!!Do not indent this if statement, #the sendmail won't work!!! if ($filesize != $sizereceived) { move_badfiles(); $badpath = substr($receivefile,41); #Start SENDMAIL open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq"); print SENDMAIL <<"EOF"; From: marc To: someone\@someplace.com Subject: Distn Planning File Error! File $badpath has not be transmitted properly. Check the badinput dir +ectory. EOF close(SENDMAIL); } else { move_files(); }#End else $timestamp = strftime("%m%d%Y%H%M%S", localtime()); $receivetime = strftime("%m/%d/%Y %H:%M:%S", localtime()); print "Successfully received $receivefile at $receivetime\n"; close($client); }#End receiving connection
In reply to Socket Server Speed by wileykt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |