Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Design decision, call backs and network data

by beable (Friar)
on Jul 25, 2004 at 08:26 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2023-03-22 09:27 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.