psyk0tic has asked for the wisdom of the Perl Monks concerning the following question:
I need some help from your church in relation to socket data manipulation.
I've made a deamon that accept conections always from the same machine (HOST1), processes the data recieved and send SNMP traps to another machine (HOST2).
The problem is that I wrote it assuming that each time HOST1 has something to send it will connect send data and disconnect, but yesterday I learned we shouldn't make that kind of assumptions...
while (defined(my $line = <$NA_Conn>)) { $input.=$line; } #processing the $input here...
So, HOST1 never disconects, it connects to my deamon and whenever it has data to send it send's... But this way the $input is never processed.
What is the best way to process the input in 'real time'?
TIP: I need to send a trap each time I get a complete 'packet' with start and end flags: #S#\n\r<lines of data here >\n\r#E#
Threads? Multiprocess? Something simpler and effective?
PS: I would prefer stability to velocity.
Thanks in advance, AMEN Monks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Real-time socket data processing
by almut (Canon) on Jun 24, 2010 at 16:47 UTC | |
by psyk0tic (Novice) on Jun 24, 2010 at 17:48 UTC | |
|
Re: Real-time socket data processing
by Generoso (Prior) on Jun 24, 2010 at 17:45 UTC | |
by psyk0tic (Novice) on Jun 24, 2010 at 17:52 UTC | |
by Generoso (Prior) on Jun 28, 2010 at 15:29 UTC | |
by psyk0tic (Novice) on Jun 29, 2010 at 11:26 UTC | |
|
Re: Real-time socket data processing
by Proclus (Beadle) on Jun 26, 2010 at 10:21 UTC | |
by psyk0tic (Novice) on Jun 29, 2010 at 11:32 UTC |