Regarding your stated question, in order to not block on your read of STDIN you need to do the same thing you're doing with your sockets; namely, select on it. Do realize, however, that filehandles attached to terminals will not normally have input ready until they see a newline, so your input will not be ready until the user hits enter.
I notice you're mixing IO::Select with buffered reads (<$rh>) and writes (print $ns). While you may sometimes be able to get away with this (there are POSIX rules, apparently, that let you), I would not rely on it.
When using select you should use sysread and syswrite (or send and recv, though you don't need the flags), as mentioned in the documentation for perldoc -f select and shown in the example code in the UDP Message Passing section of perlipc.
However, manually handling the buffers for all this can easily get tedious, so maybe you should look into an event system like Event or POE.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.