Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Querying a Server Periodically

by termix (Beadle)
on Dec 27, 2001 at 21:13 UTC ( [id://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?
Username:
Password:

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

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

    No recent polls found