This is actually a very big question. Let's say I could
tell you how to move the listen to the background. What
then? How would your program be notified when something
happened on the socket? What if your program is doing
something else when the notification comes in?
So, the roundabout answer is, you probably don't want to do it that
way. Use Fcntl to set your socket to non-blocking, and
then check it occasionally to see if anything's connected.
Or, if all you're doing
is waiting for connections and processing input, don't worry
about the non-blocking stuff. Use select and let it tell
you when something interesting happens. IO::Select is a
nice module for such things.
BTW, Richard Stevens'
_UNIX Network Programming_ is an invaluable resource for
stuff like this.
*Woof* | [reply] |
Hum, this is now definately a FAQ (not that it wasn't in the first place). See Socket.pm nonblocking
Andrew.
Update: You can also now go and see my tutorial
on this subject, complete with very silly example.
| [reply] |
There's a tutorial on
writing a chat server in Webmonkey that may help you. You
need to use select to listen for sockets that have information
waiting to be read. | [reply] |