Hi Monks,

I would like to have a simple non-blocking chat example that specifies IP addresses and ports for both the client and the server. My goal is to set up 2 boxes with 3 or 4 quad NIC cards in each. I would set up chat accross each port to start develeloping code. Once I know a little I would change gears from chatting with another Intel Architecture box and use my code to talk to numerous small embedded boxes.

I am one of those people who get to use Perl every now and then to try to do something useful in support of a hardware project. I am not an expert, but I am not exactly a beginner. I have Googled, RTFM'd, bought Lincoln D. Stein's book (a good book) and put a lot of work into this already. I am overwhelmed by code fragments, snippets, "perl chat" examples and text that sounds very useful but the "non blocking" material is on page 3xx or later and is filled with references to "this is just like the previous 3xx pages except for the differences. I'm hoping someone can give me a 5 or 6 line server example with a 5 or 6 line client example that I (consider me a beginner) can use to get a good start that I can build upon.

I'm not necessarily hung up on "nonblocking" but I don't want to get stuck. Years ago someone showed me an example (about 6 lines) where buffers and available status was checked before attempting to send or receive. I don't think that this was "nonblocking", but you never got stuck. If I still had this example I would probably have my starting point.

If the example does not specify both the local and remote IP addresses and ports then I probably will not know how to code for the various 12 or so ports. If the code is just a 3 line snippet then I usually pull the other 3 lines from the wrong example and end up with 6 lines that don't work. Somehow starting with the 60+ line samples (MANY available) and trying to distill them down to 6 lines ends up being a lot of work just to understand that this is not the right set of 6 lines to start with.

Since I want to service 12 or more ports on one box I will probably do some RTFM on threads or forks after I get a simple example running. If the simple "Hello World" had a "Part 2" that easily serviced multiple ports then I would think that Christmas came early.

Yes, I know that UDP does not guarantee delivery, can drop packets in the "real world" and a UDP Hello World will be far short of the final test code I need. I don't mind doing work, but I would sure like to feel like I am getting some bang for my buck. Beginners excel at running around in circles and I am ready for a little linear motion.

Thanks for any help,
Bruce


In reply to nonblocking UDP, "Hello World" level by Bruce32903

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.