wileykt has asked for the wisdom of the Perl Monks concerning the following question:
$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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket Server Speed
by amphiplex (Monk) on Jul 01, 2002 at 13:52 UTC | |
by wileykt (Acolyte) on Jul 01, 2002 at 14:24 UTC | |
|
Re: Socket Server Speed
by robobunny (Friar) on Jul 01, 2002 at 14:03 UTC | |
|
Re: Socket Server Speed
by Ryszard (Priest) on Jul 01, 2002 at 13:51 UTC | |
|
Re: Socket Server Speed
by Abigail-II (Bishop) on Jul 01, 2002 at 14:33 UTC |