in reply to Async socket connection
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Async socket connection
by ljamison (Sexton) on Feb 08, 2017 at 20:56 UTC | |
by Corion (Patriarch) on Feb 09, 2017 at 08:08 UTC | |
by ljamison (Sexton) on Feb 09, 2017 at 15:41 UTC | |
by Corion (Patriarch) on Feb 09, 2017 at 15:53 UTC |