in reply to Fork and pipe
Probably your game will incorporate an event loop at its core. This would be something along the lines of:
while (1) {
# do each round of your game here
if ($the_player_wants_to_exit) { &my_exit_method(); }
}
In fact, since your game involves network players, your loop most likely looks like:
while (1) {
&get_a_message_from_a_player();
# Do the rest of your game round processing here
if ($the_player_wants_to_exit) { &my_exit_method(); }
}
What I would do, is to embed the processing of new players inside the same event loop. This would be something along the lines of:
while (1) {
&get_and_process_new_player();
&get_a_message_from_a_player();
# Do the rest of your game round processing here
if ($the_player_wants_to_exit) { &my_exit_method(); }
}
IMO, this will make your life easier. Take a look at IO::Socket and IO::Select, as they are of great help for what you need here.Regards.
|
|---|