in reply to Re^2: Open&manage 2 sockets at one time
in thread Open&manage 2 sockets at one time

I never said anything about daemons.

And how is an IRC bot not a daemon?

  • Comment on Re^3: Open&manage 2 sockets at one time

Replies are listed 'Best First'.
Re^4: Open&manage 2 sockets at one time
by motzi (Sexton) on Sep 23, 2008 at 00:10 UTC
    any daemon is like a server (i think :) ) and irc bot is an client of a server. just was thinking that your last code (with var $clients) is only for IO::Socket which in local port listening mode. (sry, my perl knowlege is still very low)
      motzi:

      I think you're just getting hung up on the variable name $clients. Ikegami's first code block is showing you the basic strategy of an event-driven program as applied to sockets. At the most conceptual level, it's something like:

      while application doesn't need to quit: does task 1 need attention? Yes? Give it a little lovin' does task 2 want a hug? Yup--give it a bear hug . . . is task n unhappy? Uh huh: Give it a smile

      The rules are that (1) asking a task whether it needs attention can't take a long time--otherwise you'll starve all your other tasks; and (2) none of the tasks you're performing can take a long time, either, for the same reason. So you'll use non-blocking I/O techniques to check your sockets because a normal read without checking will wait until that socket has something to say.

      ...roboticus
      I don't understand what you mean by "local port listening mode".