Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Thread or Select for sockets?!

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://197498]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-08-07 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?