Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: POE TCP client problem

by rcaputo (Chaplain)
on Jan 11, 2010 at 06:43 UTC ( [id://816678]=note: print w/replies, xml ) Need Help??


in reply to Re^2: POE TCP client problem
in thread POE TCP client problem

I suspect I misunderstand your protocol. Based on my reading of your sample code, the timing seems to be:

  • Client sends a file to the server in response to establishing a successful connection.
  • Server receives the client's file and sends a file to the client in response.
  • Client receives the server's file and sends a file to the server in response.
  • The last two steps repeat until some ending condition is reached.

That sort of protocol tends to be self-synchronizing. Neither the server nor the client will send a file out of turn, so logic for handling out-of-turn files isn't necessary. If it weren't for the client taking initiative, nothing would happen at all.

If you want to identify when one or the other side is desynchronized, then you can store a "sender" or "receiver" state in a variable, or in $_[HEAP]. The client begins in the "sender" state, and the server starts in "receiver" mode. If input arrives when a client or server is in "sender" mode, that's an error. Each side switches from sender to receiver upon successful transmission of a file. Each side switches from receiver to sender upon successful receipt of a file.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://816678]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-23 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found