Frodo - my bad, I cut&paste'd the wrong contiguous sections of my original code. Earlier on I was trying to receive and send from the same socket, but when this started giving me problems I created a pair of individual receive and send ($s_receive and $s_send) respectively. I did try to implement this in a single socket initially, I just posted the updated code by accident.
Sorry for the confusion (see my UPDATED example in the original reply).
The following section was taken from an example I found online:
print $s_socket "$match\n";
print scalar <$s_socket>;
If it's unnecessary I can take it out - it worked so I didn't mess with it. What was the original purpose behind this "scalar" anyways?
Regarding the example you provided me, I have one primary question:
If I use a single socket for two different clients, can I still distinguish between which client I am connected to? What if my Third process connects to $conn1, and my First to $conn3 just by the order in which they happen to reach the Second process?
Is it better to setup individual ports/connections/sockets for two different clients, and then use those individual ports in a bidirectional manner?
One other thing I'd like to ask: Given that these processes will likely all be on the same machine - is there a better means of IPC to use other than sockets?
Sorry again about mangled code - I've been up for awhile:)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.