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

Ok, but i have a deal with irc bot on 2 servers in one time (i need it all at same script), its not about a daemon. Can your method be applied for my issue?
  • Comment on Re^2: Open&manage 2 sockets at one time

Replies are listed 'Best First'.
Re^3: Open&manage 2 sockets at one time
by ikegami (Patriarch) on Sep 22, 2008 at 22:15 UTC

    I never said anything about daemons.

    And how is an IRC bot not a daemon?

      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".