in reply to Testing many devices - are threads the answer?

This sounds like a problem with lots of potential solutions.

The approach I was thinking about depends on how you need to test each individual AP. You say it's via telnet, and (in a follow up posting) that you want to increase the timeout to avoid false positive, so maybe the algorithm looks like this:

  1. Open socket
  2. Connect (TCP) to telnet port on AP
  3. Send "Are you OK" message
  4. Wait for long enough for healthy AP to respond
  5. Read from socket
  6. Work out from reply whether AP is OK or not
  7. Close socket
If this is the algorithm for each AP, then this can be scaled up either by creating threads (or processes) which can all follow the same sequence (as described above) or alternatively just process an array of APs in parallel:

  1. Open 10 sockets
  2. Connect to 10 APs
  3. Send 10 messages
  4. Wait Once
  5. ...
Maybe this approach isn't suitable for you (maybe your AP testing is too wrapped up in a module/DLL) but it might be suitable for someone else with a generally similar problem who stumbles accross these posts in future.

--
use JAPH;
print JAPH::asString();

  • Comment on Re: Testing many devices - are threads the answer?

Replies are listed 'Best First'.
Re^2: Testing many devices - are threads the answer?
by BrowserUk (Pope) on May 13, 2009 at 14:13 UTC
    Open 10 sockets

    You are still opening the 10 sockets serially, and if the first machine isn't there, you will have to wait for the open attempt to fail--timeout--before moving on to the second...


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      you will have to wait for the open attempt to fail--timeout--

      Not true if you open the socket in non-blocking mode.

        Could you expand on that a little?

        Maybe its a platform limitation, but how do you get hold of the socket to set it non blocking before you've opened it? Setting Blocking to 0 on the open doesn't cause the open to return immediately if the peer isn't there on my platform.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.