i stand absolutely corrected. i guess i am showing the fact that some of the things i learned are no longer quite as accurate as they were when i picked them up :) so, i wrote a bit of code to test this out:
#!/usr/bin/perl -w use strict; use IO::Socket; use Benchmark; my $to_mail_addy = "junk\@????????.net"; my $from_mail_addy = "junk\@????????.net"; my $mailhost = "localhost"; sub with_pipe { open(SENDMAIL, "|/usr/sbin/sendmail") or die "cannot open sendmail" +; print SENDMAIL "To: $to_mail_addy\n"; print SENDMAIL "From: $from_mail_addy\n"; print SENDMAIL "Subject: A speed test...\n"; print SENDMAIL "Content-type: text/plain \n\n"; print SENDMAIL "Blah blah blah... this is my content..."; close(SENDMAIL); } sub with_socket { my $sock = new IO::Socket::INET(PeerAddr => 'localhost', PeerPort => 25, Proto => 'tcp'); die "unable to create $sock" unless defined $sock; print $sock "Hello arino.net\n"; print $sock "MAIL FROM: $from_mail_addy\n"; print $sock "RCPT TO: $to_mail_addy\n"; print $sock "DATA\n"; print $sock "Subject: A speed test...\n"; print $sock "Blah blah blah... this is my content..."; print $sock ".\n"; print $sock "quit\n"; close($sock); } timethese (1000, {"WITH PIPES" => \&with_pipe, "WITH SOCKET" => \&with_socket }); [ed@darkness ed]$ perl speedtest.pl Benchmark: timing 1000 iterations of WITH PIPES, WITH SOCKET... WITH PIPES: 22 wallclock secs ( 0.26 usr 0.68 sys + 6.95 cusr 4.93 +csys = 12.82 CPU) @ 1063.83/s (n=1000) WITH SOCKET: 17 wallclock secs ( 1.76 usr + 1.13 sys = 2.89 CPU) @ 3 +46.02/s (n=1000)
so we see that sockets ARE much faster than pipes, which to me was counter intuitive... I guess they really have optimized the bejeezus out of the TCP stack... time to have a little chat with my networking professor :)

UPDATE: out of curiosity, people have asked what the system specs were like on the machine i ran the tests on:
Processor Pentium II (Deschutes) 348.491034 Mhz
RAM Memtotal - 193060 kB
MemFree - 20864 kB
OS Linux 2.2.13 i686 (redhat)


In reply to RE: RE: RE: RE: eof without closing the pipe by eduardo
in thread eof without closing the pipe by csorensen

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.