Leostereo:

I've not tried your code, but I looked over the Parallel::ForkManager documentation and noticed one thing: Just as in the normal fork() system call, Parallel::ForkManager returns a PID (Process ID) to the parent process. P::FM uses that to tell you when you're the master/parent process vs. the child process. In the P::FM example, they use that fact to get the parent process to skip the child tasks work, which (as you'll notice) contains the $pm->finish call. Otherwise (and this is the hint!) the parent would *also* execute the $pm->finish task, and quit. (Mea culpa: you *did* have a PID check in there, I managed to miss it!)

So I'd suggest you do more like:

. . . callback => { data => \&data, add => \&start_new_cnx, }, . . . # Let the connection start up, and spawn a thread to handle it. # Returns 1 for both parent and child task, so the connection isn't cl +osed. sub start_new_cnx { $pm->start; return 1; } sub data { # the same as you had it, but get rid of the $pm->start call, as it +'s # already been started. Just call $pm->finish when you want to end # the connection and terminate the task. }

I've not tried this out yet, I just read the docs of both P::FM and IO::Socket::INET::Daemon, neither of which I've used (AFAIRemember).

Update: That wasn't your problem. I installed the packages and tried my suggestion of forking in the add callback, and had no better luck than you did. I'll try playing with it a little more and see if I can get it going.

Update 2: OK, I'm not going to mess around with this any further. I suspected that BrowserUk probably had something multithreaded with sockets somewhere around here, and found this thread in which BrowserUk assists Random_Walk getting a similar program going. You may want to review that thread and/or search for other BrowserUk threading-related threads.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: IO::Socket::INET::Daemon and Parallel::ForkManager working togheter by roboticus
in thread IO::Socket::INET::Daemon and Parallel::ForkManager working togheter by leostereo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.