Dan, Sounds like you're moving into the realms of threads. Perl 5.8.0 has stable threading support. Install it and type 'perldoc perlthrtut' for details. If you take a threaded approach to solving this problem, you'll probably have a main thread of execution that launches seperate threads for each connection using blocking sockets for network IO. And then you'll have an additional thread that responds to events. An event can be generated by some network traffic from a user or a timer expiring (as in your example). Then you'll have a seperate thread that loops through your data structures checking if timers have expired and sending the appropriate events to your event handler.
Something like that. The other approach which will give you MUCH better performance, but will be more complicated to code, is to use non-blocking sockets for your network IO and to just code your application as one big loop that continually checks for network traffic and then quickly loops through your data strucutures to see if any events need handling. Non-blocking sockets are kindof complex to code, but they give you much better performance than blocking sockets because you dont have the overhead of managing multiple threads of execution. Just FYI, blocking sockets are sockets that pause the execution of your application until an event occurs on the socket like data arrives to be read. They're a real pain if you're trying to handle multiple sockets in a single thread of execution, because when you try to read from the socket, everything freezes until you have succesfully read. non-blocking sockets dont halt execution - they just give you a status saying 'I would have blocked' and you can continue doing other stuff while periodically checking back to see if the thing you're waiting for has happened yet. I know I seem to be digressing here from your original question, but I think your question is really 'how do I handle time critical network events while doing lots of other less important stuff concurrently?'. ~mark. On Tue, Sep 17, 2002 at 02:53:11PM +0100, dan wrote: > I'm writing IRC services in perl (some say it's a bad idea, others good, I > personally don't care what the language is, it has a fast response time and > does what I want it to do), however I need to have a sub to check bans every > second, to see if it should time them out and remove them. I have the time > to expire it in unix timestamp seconds: > $akill{$host}->{expires} > I need to make a sub to run through all the %akill keys one by one every > second to check if it should time them out. However I need it so the timer > doesn't interfere with the rest of the code, i.e responding to users on the > network normally as if the timer isn't even working. > > Any clues? > > Dan > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]