Lots of things said in the first reply is actually wrong. select does not have the magic to redirect standard output.
Shocking! pg is usually right, but the first reply is completely accurate and highly educational! Here is a version of the original program with timestamps added:
$queuelength=1; use Socket; socket(HANDLE, PF_INET, SOCK_STREAM, getprotobyname('tcp')); $addr = sockaddr_in(80, INADDR_ANY); bind(HANDLE, $addr); listen(HANDLE,$queuelength); while(true) { print "hallo1\n"; print STDERR "before accept ", scalar(localtime), "\n"; accept(NEW_HANDLE, HANDLE); print STDERR "after accept ", scalar(localtime), "\n"; select(NEW_HANDLE); print STDERR "after select ", scalar(localtime), "\n"; $line=<NEW_HANDLE>; print STDERR "after readline ", scalar(localtime), "\n"; print $line; print STDERR "after print ", scalar(localtime), "\n"; print "hello2\n"; } __END__ Output: before accept Sat Oct 11 16:01:55 2003 after accept Sat Oct 11 16:02:44 2003 after select Sat Oct 11 16:02:44 2003 after readline Sat Oct 11 16:02:44 2003 after print Sat Oct 11 16:02:44 2003 before accept Sat Oct 11 16:02:44 2003 after accept Sat Oct 11 16:03:12 2003 after select Sat Oct 11 16:03:12 2003 after readline Sat Oct 11 16:03:12 2003 after print Sat Oct 11 16:03:12 2003 before accept Sat Oct 11 16:03:12 2003
Note that the only pauses are for the accept() call, not select(). And you can see a screen shot with two browser windows as well as the perl program in a DOS box here. The select() call redirects the standard output to a socket which sends is connect to a browser.

In reply to Re: Re: Perl socket server problem by Thelonius
in thread Perl socket server problem by pego

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.