Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

blocking?

by Punto (Scribe)
on Jun 05, 2001 at 09:49 UTC ( [id://85761]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

Punto has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I have 2 questions about blocking:

Is there any way to accept a connection on a socket without blocking the program? I'm using accept() on an IO::Socket::UNIX, but I think that blocks the program.

Is there any way to read data from a filehandle without blocking the program? I think I saw something about select(), but the reference on perlfunc is not clear (actually, it seems it doesn't have anything to do with it).

Thanks..

Replies are listed 'Best First'.
Re: blocking?
by jeroenes (Priest) on Jun 05, 2001 at 09:54 UTC
    You need to fork your script, in both cases. Search on forking, turns op many good threads. For example. read the nodes of For all your forking needs...

    Jeroen
    "We are not alone"(FZ)

(tye)Re: blocking?
by tye (Sage) on Jun 05, 2001 at 15:07 UTC

    select in Perl has two very different meanings. If you pass 4 arguments to select, then it offers the function that you need. These two uses of select are so different that they are documented separately. Right after the section on select that you read, you'll find another section on select that describes what you need.

            - tye (but my friends call me "Tye")
(dws)Re: blocking?
by dws (Chancellor) on Jun 05, 2001 at 18:38 UTC
    Is there any way to accept a connection on a socket without blocking the program?

    A bit of advice: Everything you're liable to need to know about writing non-blocking servers is covered in Lincoln Stein's Network Programming With Perl. Spend the bucks on the book. It's well-written, and will spare you lots of grief.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://85761]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.