Sample Host and Remote Agents

Visual Basic Host Agent

The actual implementation of a simple host agent in Visual Basic is shown next. The host agent application looks like the simple form below.

Each of the five steps requires only a few lines of code.

  1. The host periodically checks for new request.

    We can set the responsiveness of the system by changing the timer interval. We permit only one query to be active at a time by using a static variable.

  2. The host searches for any pending files.

    We check for any files in the incoming directory.

  3. The host uses the data in the request to execute query.

    If a file is found, we start to process it. The file must be in the appropriate format; in this case, the first character on a line must be correct and the keywords in the SQL query must be in capitals.

  4. The host saves result sets.

    If result sets are returned, they must be placed into the specified table. This means modifying the query somewhere. It may be done at any agent or in the application, but it must be at one place only.

  5. The host compresses the file if requested.

    The following section shows how we can compress an MDB with a common utility. A 65,536-byte database may be reduced to only 5,888 bytes, resulting in significantly shorter transmission times.

  6. The host deletes request file.

    The signal that the result set is ready to be picked up is the removal of the query file.

Visual Basic Remote Agent

The actual implementation of a simple remote agent in Visual Basic is shown next.

Each step requires only a few lines of code.

  1. The remote agent sends the request.

  2. The application must use a scheme to prevent collision. A counter is an effective one.

  3. The remote agent waits until the request file is deleted.
  4. The timer permits periodic checks.

  5. The remote agents copies the database (or zipped file) and deletes it from the host.

  6. The remote agent assigns results.
  7. The assignment of results is always application-specific. A good schema is to have one MDB match each form. In our sample application, we implemented a generic form.