duancg has asked for the wisdom of the Perl Monks concerning the following question:
As part of my mod_perl HTTP request handler, I need to send (simultaneous) socket requests to backend servers (and then aggregate the results from backend into actual HTTP responses). And to make sure my handler don't block, I would need to set a timeout of those backend socket requestes around 20ms or so.
So far, I am using Thread::Queue and threads packages to hook the pre-allocated worker threads with the main thread. However, I am a bit confused how to do the following in worker threads:
I read about APR::Socket APIs (http://perl.apache.org/docs/2.0/api/APR/Socket.html) but am confused about how to create a $sock object from host name and port number.
Could you monks help with a sample code snippet? Or any other packages/ways to do the same? Thanks!
|
|---|