|Problems? Is your data what you think it is?|
Re: Re: Re: Re: Re: How do I close a POE SocketFactory Socket?by rcaputo (Chaplain)
|on Jun 27, 2002 at 05:37 UTC||Need Help??|
If I understand correctly, you want the server to start talking first. That's easy, really. POE::Wheel::ReadWrite instances are ready to be used immediately.
POE can be used to write single-tasking programs that block, but network servers don't usually don't fall into this category. It's possible to block temporarily, though, and short blockages might go unnoticed. (Actually, a POE program is just a series of very short blocking operations. They usually occur quickly enough that people don't notice.)
The heap is reserved almost entirely for your storage. Its main purpose is to store persistent information between events. If I understand your question, this is exactly what you want to do.
If you decide to keep copies of socket handles in the heap, be sure to delete them when you're done with them. Otherwise your server will leak memory and file handles, and it will crash in short order.
If at all possible, however, you should use $wheel->put() to send data. Your $socket is in non-blocking mode, and all the standard caveats about print() and <> apply.
If you're going to store a lot of things in the heap for each wheel, consider turning things inside out.
Then you can delete it all at once.
Interview? I get this sort of Q&A all the time. :)