I am trying to code up a project for a class - the assignment is to create 3 separate processes, each reading from an individual file; an alphabetical list of names with no set length (in otherwords, the file list is presumed to be infinite). The processes must coordinate with one another to find the first name that is on all 3 lists.

Okay so enough with the details...

I am trying to have each process communicate via a pair of sockets (send and receive) respectively for each script. At present I have a total of 8 open sockets, two for First.pl, four for Second.pl (since it is the middleman) and two for Third.pl.

My issue is being able to read from two open receive sockets at the same time, for some reason I cannot seem to keep two open "receive" streams. Also I seem to have issues printing to STDOUT on a process while it has a socket-stream open to another process<\p>

Is there a more intelligent way of going about this?

If not, what are the pitfalls I may be stumbling across in my implementation?

I will post some code in the next hour or so - it's pretty mangled at this point (5am CST) and needs to be cleaned up before going public. In the interim, any advice would be much appreciated!


In reply to sockets and such in Perl by scotchfx

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.