HOLY COW! I'm totally inspired by your "nothing cannot be done in Perl" attitude. It took me some time to digest that code, and I finally came up with my interpretation of that. I hope this helps many others who are on the same (average) level as me and facing the same problem too!
#!/usr/bin/perl use strict; use warnings; use Carp; use English '-no_match_vars'; use charnames ':full'; use Readonly; use Readonly::XS; use threads; use IO::Socket; use version; Readonly::Scalar our $VERSION => qv(0.0_1); $OUTPUT_AUTOFLUSH = 1; # IOCTL code to enable or disable non-blocking mode on a socket Readonly::Scalar my $FIONBIO => 0x80_046_67e; # Create a UDP server socket as input??? Pick a random port number my $in_sock = IO::Socket::INET->new( LocalAddr => 'localhost', LocalPort => 0, Proto => 'udp' ) or croak 'Failed to open port'; # Enable the newly created input socket's non-blocking mode my $true = 1; ( ioctl $in_sock, $FIONBIO, \$true ) or croak $ERRNO; # Create a UDP client socket as output??? Bind it to the input socket +created # earlier my $out_sock = IO::Socket::INET->new( PeerAddr => 'localhost', PeerPort => $in_sock->sockport(), Proto => 'udp' ) or croak "Failed to bind remote port $in_sock->sockport()"; # Don't really get the mechanics behind these. Just copy and apply for + now threads::async { while (<>) { $out_sock->send($_); } } ->threads::detach; # A simple test to prove that it is non-blocking while (1) { sleep 1; print "\N{FULL STOP}"; } 1;
While the script is running, I can even hit Backspace to erase the contents on the screen!

In reply to Re^4: Any event modules that support STDIN polling for Windows? by KHLeow
in thread Any event modules that support STDIN polling for Windows? by KHLeow

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.