Hry Mark,

While I'm significantly less qualified than many on the POE list, I will give 
it a shot.


Part of what POE has taught me is to organize my code into more distinct steps 
where  I can stack them up and execute them asynchronously.


Part of the thing with Fork is that when you look under the covers, it clones 
the process.  So, every time you fork, you create a new instance.


With POE, you organize the things you need to do in subroutines accessed via 
Call backs.  When you need to something that blocks, you use a Run Wheel to 
keep your process working. 


Everything starts off with a _start.  In this sub, start up your SocketFactory 
stuff, your Run Wheels, etc.  If these need to be done is  specific order, use 
a yield yo callback to the stack a separate subroutine to start the other 
things.


As things start running and you accept connections, each accept sets up 
callbacks for each thing you need to do.


Look at delay_add to setup a delayed timer. Wait and sleep block... And when 
they do, so does everything else.


I built an event management system capable of handling and processing > 1 
million events a minute.


HTH,


Dougie!!!








-----Original Message-----
From: Mark Richards <mark.richa...@massmicro.com>
To: poe <poe@perl.org>
Sent: Sun, Dec 9, 2012 3:15 pm
Subject: Custom server


I think POE would be a good choice for what I am about to describe, but 
there are a few bits I am not certain about (how to implement; whether 
it's possible to implement).

I already have a working model of a server that listens on a designated 
port (built in php!). It forks each connection request and handles these 
independently.  There may be one or 100 clients connecting at any time.  
However there is the problem of zombies, and the lack of centralized 
control and reporting.  I want to build this in perl, and feel POE would 
be a good choice.

My server waits for a connection.  The client, once connected, sends a 
header that contains its ID and WAN IP address.  The server reads this, 
and responds by either continuing some communications with the client, 
or dropping the connection if it is not validated.

A valid connection provides a MODBUS ASCII session with a MODBUS network 
attached to the client.  So the server instance sends some MODBUS 
commands and gets data in response.  In the present implementation the 
server keeps the connection alive for 10 minutes (this is a design 
requirement - don't ask!), and then drops the connection (this is where 
we get the zombies from).

What I need POE to do is the same thing, but for this I think I need a 
manager of some kind that will, based on the state of the exchange, 
dispatch the proper request.  Each remote may require a different set of 
requests, which further complicates things.

I've thrown together a simple POE version of my server.  It simply 
accepts the connection and reads in the first data from the client (a 
header).  What's missing is a way to dispatch requests dynamically and 
also to wait without making the whole POE instance wait.

Hoping I have described this adequately, and that the experienced out 
there might offer some suggestions as to how to approach this - and 
whether POE is the right move.

Thanks!


 

  • Custom server Mark Richards
    • Re: Custom server Douglas W. Stevenson

Reply via email to