I havn't tried to run your code yet, but I have been playing around with socket servers, including threaded, forked, and selected.
What I have found is if you want to make a chat style server, where the output from the clients is echoed to all the other clients, you should use select or IO::Select methods in the server. With a forked or threaded server, it gets pretty complicated to try and "share" the data between different forked
or threaded servers. I observed the forked server or threaded
server, gets a copy of the parent's variables, when it gets created. So for example, the third spawned threaded-server will be able to write to numbers 1 and 2, but 1 and 2 cannot
write to 3, because server 3 didn't exist in the parent when they were created.
If you have threads::shared working in a fashion that updates all threads when a new thread is created, properly
passing the new socket, I would like to see it and play with it.
Otherwise I have a couple of chat servers using IO::Select
or plain select, I could post for you.
Do you have a place to post your whole code? So we can download and test it?
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.