views:

118

answers:

1

I have a Perl server and when it boots up, it connects to 1000+ clients. It takes about 30-45 minutes to setup all the connections with SSL. I'm trying to decrease the start time to something more reasonable. I tried playing with threads to offload the work, but can't get it to work. Creating the socket in one thread and getting it back to the caller doesn't quite work as expected. Tried passing the file descriptor and recreating with IO::Socket::SSL->new_from_fd() to recreate the socket back in the caller but fails.

Does anyone have any suggestions as to how to approach creating this many sockets quickly? Or at least faster than O(n)...

UPDATE: Looks like POE framework is definitely something that I want to explore. The docs sound like it can do what I need. I'm building a Proof of concept now and having trouble specifically with accessing the created Socket objects in the Sessions. I can create the sockets in the POE sessions, but then after they are done, I want my main program to collect the created sockets into one hash. Anyone know how to retrieve objects from POE Sessions?

UPDATE: Have an idea involving either using a global variable and adding the sockets to that within the sessions, or keeping references to the created sessions and accessing their heaps to aggregate them. Trying it now...

+3  A: 

Have a look at this TCP SSL Client code in POE. The example can be easily extended to do what you requested. If you haven't coded in POE before, there's a learning curve, but it's very well documented.

miedwar
thanks I will take a look at that and see if it does what I need
casey
POE definitely looks like it can do what I want. Thanks for the tip. I'm trying to build a test/Proof of Concept before I work it into my real code and you were definitely right about the learning curve. I understand how to create my sockets in POE sessions, but I'm having trouble getting an IO::Socket::SSL object back into the main program. The docs say that it is possible to access the data stores of the sessions, but I can't figure it out. POE Logic-start a bunch of sessions, each creating and storing within themselves a bunch of Sockets. At the end, collect all of them in the main program.
casey
Would you or anyone with POE experience have any tips accessing the data store of the sessions to collect my created Socket SSL objects?
casey
think i have an idea using either a global var or keeping a reference to the session and accessing it's heap, trying it now...
casey
This is probably what I want, just haven't gotten it to work yet.
casey