Can I learn some more about your application, please? In return, I'll try to come up with some appropriate code ;-).

I've just deleted two potential posts trying to second-guess what you want, so I thought I'd just ask instead. Do you want to use UDP because you have very low latency requirements? Is it because you think it will be simpler to start with that and then move to TCP? Will the chat be application-to-application or person-to-person?

Note that you don't necessarily need a threaded or forked application to handle multiple clients for UDP or TCP.

Some background info, sorry if you know it all already.

UDP: each packet sent is standalone. There is no concept of connection. Packets can be dropped and also delivered out of order. If your server side doesn't need to do anything else, it can sit in a loop reading packets from the socket and responding to them, without any nonblocking, selecting, forking or threading.

TCP: a connection is made to a server socket which is listening on a specific port. The server accept()'s the new connection, which creates a socket for that two-way connection. Data read and written is transmitted reliably and in-order. The server needs to manage multiple sockets: the listening socket and all current connections. This can be done with threading/forking or using select (or it's OO wrapper IO::Select), without any need for non-blocking (if the server is doing nothing else).


In reply to Re: nonblocking UDP, "Hello World" level by jbert
in thread 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.