[tpm] Event loop, redux

Madison Kelly linux at alteeve.com
Fri Jun 13 05:54:10 PDT 2008


Hi all,

   A while ago I was asking about event loops. Richard and Mike 
recommended I look at POE, and well, as Alan put it, it's an OS written 
in Perl.

   Very impressive, but very overkill for my needs. :)

   I've got a pretty simple problem which I would like to solve using as 
simple a solution as possible. To avoid further module dependency, I'd 
also like to avoid using non-core modules, if possible.

   I've got a simple server program that listens for TCP connections 
from clients which, on connect, spawns a child process to handle the 
client. Already I can talk between the client and the server to 
establish a connection (password verification), but then I am stumped, 
so I close the connection.

   What I want is a way to keep the connection open (indefinitely, or 
until a given event/timeout occurs). At this point, communication will 
always be initiated by the server, so I just need to event loop listen 
to commands from the server, then send the request to the client, wait 
for the reply, process the reply, then go back to wait. Ideally, the 
loop could be asynchronous, but simply having a way to queue calls would 
work, too.

   Any suggestions?

   My googling has shown me for 'perl event loop tutorial' has turned up 
example using various existing modules (ie: using gtk libs)... I need 
something very generic. :)

Thanks for letting me ask so many questions!

Madi


More information about the toronto-pm mailing list