I'm running a socket server program that receives files from a perl client. When the files are received, they are printed out to a directory. The programs function fine, the question I have, is does anyone have suggestions on how to speed up the receipt of the files? It's not as fast as I'd like it to be. Below find the main portion of the socket server code.

Thanks - Keith
$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

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.