Hannes <> wrote:
> I'm wondering if it's possible to use sockets for the folloing purpose:
> A running process acts as a kind of server, sometimes it receives some data.
> The receiving should trigger some functions (some display update based on
> the new values received). While waiting, the process should be responsive
> to local user-interactions.
>
> I'm new to networking/socket programming and don't know how to implement
> this in a way that the receiving of data triggers some sort of callback and
> waiting for the receiving of the data without beeing "locked"
The best way is to put the sockets into non-blocking mode and use an
event loop. If you are doing the display using Tk or Gtk then these
toolkits provide an event loop already; if not then there are systems on
CPAN such as POE and stem that provide pre-packaged event loops which
you may find helpful.
Ben
--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased]