I don't understand your specification.

You talk about "client" and "server", but later on talk about "PC1" and "PC2". Is "PC1" a client or a server, or should "PC1" be both, client and server? (then, it would be neither)

If you mean that PC1 should have one socket for incoming connections on port 8010 and one port for outgoing connections to port 8000, this still doesn't show me what the TCP connections between the two machines PC1 and PC2 would look like. Maybe you can draw a diagram of the machines, open listening ports and which machine connects to which machine from/to which port.

I don't understand the flow of your ADD, STAT and RESP messages. I think it would make things clearer if you show not only which machine sends them but also over which TCP connection(s) the messages are sent. Also, you mention closing connections, which makes the protocol sound even weirder, but maybe showing a sequence diagram here makes things clearer for me.

As for implementing the communication, I am somewhat fond of using Future nowadays as that allows me to mostly avoid the callback hell.

A bit more low-level would be AnyEvent or Net::Async or maybe POE for handling the multiplexing of sockets.

If you want to implement your own multiplexing (which I don't really recommend except as a learning exercise), have a look at IO::Select and then select.


In reply to Re: Async socket connection by Corion
in thread Async socket connection by ljamison

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.