I'm thinking about doing a simple UDP Server/Client program to improve my rather weak perl abilities.
I basically choose UDP over TCP/IP because I haven't got the hang on threading/forking, which seems to be
necessary when you want to do a multi-client TCP/IP server.

But with UDP I stumbled across another problem. Since data could be received in any
order from any user I need to sort the input and work through it.

Now I thought of a loop that does the following for every incoming packet :

- Identify which user sent the packet (So they would need to contain something like header data)
- Check which number this packet is in a row of packets by the same user (03 of 07 for example)
- Put the packet in some nested data structure
- Check whether the packet row of some user is completed :

- if yes -> echo the packets to the other users
- if no -> next loop

Is this the (or a) "right way" to do this? Or is there a better solution (which certainly wouldn't surprise me).
Or am I missing something more fundamental?

I am thankful for any help.

In reply to Developing an UDP chat server/client by Mandor

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.