Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Design decision, call backs and network data

by beable (Friar)
on Jul 25, 2004 at 08:26 UTC ( [id://377247]=note: print w/replies, xml ) Need Help??


in reply to Design decision, call backs and network data

I think you'll have to add code to your main loop to handle the packet when it comes in, and pass it off to the subroutine that can deal with it. Here's some pseudocode:

MainLoop: while ($packet = getpacket()) { if ($packet == RESPONSE_PACKET) { deal_with_response(); } else { dispatch_packet(); } } sub dispatch_packet { my $packet = shift; if ($packet == NORMAL_PACKET) { ordinary_handler(); } elsif ($packet == SPECIAL_PACKET) { special_handler(); } } sub ordinary_handler { whatever(); } sub special_handler { ask_for_info(); # save the state so that we can deal # with the response later save_state(); } sub deal_with_response { # get the saved state and deal with the response load_state(); talk_to_the_hand(); } __END__

The implementation details are left as an exercise for the reader.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found