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

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)
  • Comment on Re^4: Open&manage 2 sockets at one time

Replies are listed 'Best First'.
Re^5: Open&manage 2 sockets at one time
by roboticus (Chancellor) on Sep 23, 2008 at 11:09 UTC
    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
Re^5: Open&manage 2 sockets at one time
by ikegami (Patriarch) on Sep 23, 2008 at 04:40 UTC
    I don't understand what you mean by "local port listening mode".