rendler has asked for the wisdom of the Perl Monks concerning the following question:

First off I'm making a fake IRC service, I have a while loop at near the very end for the client connection to sit on and accept any commands and send the client new messages. All of this after the client has already been authenticated and connected to the server. The problem I'm having is while waiting for the client to send commands in that while loop, how do I also send things back to the client at a pre-defined intervals? I've been trying to do this with weird tricks using alarm but all that is doing is randomly disconnecting the client.

Replies are listed 'Best First'.
Re: Doing stuff while doing other stuff
by sauoq (Abbot) on Sep 21, 2002 at 00:38 UTC

    You are blocking until you get input from the client. You want your reads to timeout. You'll need to use select() for that. IO::Select comes with Perl and provides an object oriented interface that hides some of the details from you.

    -sauoq
    "My two cents aren't worth a dime.";
    
      I have no idea how the heck how I'm meant to be using IO::Select from all ther docs and examples I've seen my head just hurts more and more as I try to understand it :( Is there a VERY basic tut/example out there?
Re: Doing stuff while doing other stuff
by BrowserUk (Patriarch) on Sep 21, 2002 at 00:19 UTC

    Take a look at the docs on select. It's probably what you are seeking. It's difficult to be really sure without sight of your code.


    Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
Re: Doing stuff while doing other stuff
by rendler (Pilgrim) on Sep 21, 2002 at 08:39 UTC
    Problem soved using fork, thanks for the replies.