Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Is it possible to wait for data in a socket 'in the background'?

by Anonymous Monk
on Feb 13, 2001 at 03:04 UTC ( [id://58015]=perlquestion: print w/replies, xml ) Need Help??

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

I have created a GUI program from Perl/Tk but it freezes whenever there's no data coming from the socket. I would like the program to maintain user interactiviy while the program listens for data from the socket. Here's part of my code.
build_gui(); ## sets up the gui_interface exit; sub build_gui { ## sets up a button and other widget)} ## invoked when user pressed a button sub event_handler { $handle = IO::Socket::INET->new("$host:$port"); while (<$handle>) # my program freezes here as it # waits for data in the socket { ## do stuff and then updates the GUI interface } }
Thanks in advance for the help.

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: Is it possible to wait for data in a socket 'in the background'?
by dash2 (Hermit) on Feb 13, 2001 at 23:16 UTC
    This node also contains a lot of useful information. Mostly also contributed by agentM, I believe.

    dave

Re: Is it possible to wait for data in a socket 'in the background'?
by AgentM (Curate) on Feb 13, 2001 at 03:17 UTC
    Besides the obvious answer (select- Unix-style or IO::Select), you may want to look at POE for advanced design.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-29 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found