![]() |
|
go ahead... be a heretic | |
PerlMonks |
Re: Thread or Select for sockets?!by Preceptor (Deacon) |
on Sep 13, 2002 at 10:20 UTC ( #197498=note: print w/replies, xml ) | Need Help?? |
Well, not to blow my own trumpet _too_ much, have a look at this. It's a mud client (read almost telnet but not quite) using IO::Select. IMHO this is the more elegant way than threading or forking, since you neatly sidestep the delightful things known as 'concurrent issues'. Threading requires a certain amount more thought, especially when you do anything to modify a 'global' value. (Some models, threading is good, like for example, I'm currently hacking together an FTP download manager for which it'd suit well. Others, it's just overkill, and potentially dangerous.)
Update: Be aware that some network calls, such as 'gethostbyaddr()' at the OS level are NOT thread safe. I don't know how perl deals with this, but it's one to watch for. -- It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
In Section
Seekers of Perl Wisdom
|
|