You should take a look at IO::Socket, or if your familiar with sockets in C (and don't want to do it the easy way), then take a look at Socket.pm
Also, if you considering handling it without forking, take a look at IO::Select (again, if you're a glutton for punishment, just use select and have fun with your vectors)
As to whether multiplexing, or forking is better, it kinda depends on preference, and on the application. I generally prefer to do forking when I have my choice or either will do.
When doing forking, you need to decide if you want to fork as needed, or do preforking (similar to what Apache normally does), also you'll want to keep track of your children (you don't want to fill up your process table do you?). Also, don't forget to set $SIG{CHLD} properly to deal with dead children
I personally feel that forking on demand is the easiest set up, but multiplexing can give you some tighter control (for instance, if for each connection, you'll be accessing a single resource constantly, a multiplexed server would be easiest to eliminate contention)
I believe there are also some good examples in the Perl Cookbook, and in Advanced Perl Programming (both from O'Reilly of course)
Hope that helps,
cephas
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.