Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Querying a Server Periodically

by termix (Beadle)
on Dec 27, 2001 at 21:13 UTC ( #134648=note: print w/replies, xml ) Need Help??

in reply to Querying a Server Periodically

If the server and client are talking through TCP/IP and you are using sockets to implement that then you should be able to use select to detect when an event happens. You can use a time out with select.

I believe a quick and dirty implementation could involve forking the client so that the parent handles communications (the select loop), while a child handles the user interface. The child and parent can communicate through TCP (or UNIX sockets) and the parent will be able to deal with that in the same select loop.

client program connects to the server (fd a) client program opens the windows etc. client program forks. parent: wait for the child to connect. go into select loop (blocking) was it the server :---> paint the incoming message was it the child :---> send message to server was it the child and user wants to quit:-> shutdown (remember to kill child). child: connect to parent loop: if user types something send to parent

Hmmmm... Inelligant I believe, but then I'm not being graded on this (am I?). Multi threading would be much better. But I don't know what that would do to Perl/Tk

-- termix

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-06-03 22:19 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (17 votes). Check out past polls.