Carapace

Scripted Comms Modules

A ScriptModule wraps up a class implemented in Carapace script.

The following high-level protocols are implemented in Carapace script:

Ftp file transfer protocol
Smtp mail transfer
Http web support
Pop3 message store access

Click here for an example of a scripted comms module which can be wrapped up in a ScriptModule.

ScriptModule Creation

Given a scripted class which obeys the rules, a ScriptModule is made using the create function function. For example, the following creates a ScriptModule to wrap an Http module:

    (create ScriptModule "Http")
The following pushes an Http module onto a stack:
    (stack.push (create ScriptModule "Http"))
The Http module can be recovered from the stack as follows:
    (stack.top)
assuming the Http module is at the top of the stack.

ScriptModule Properties

A ScriptModule supports only the standard comms module properties ie.

property name property type description
log Log a log for the communications

The existence of a property called isBottom on the scripted module allows the module to be placed at the bottom of a communications stack.

ScriptModule Methods

A ScriptModule supports only the standard comms module methods ie.

method name description
connect connect this module
receive receive data
receiveInto receive data into the supplied buffer
send send data
disconnect disconnect this module
bind bind address information for this module
listen prepare to listen for new connections
accept wait for a new connection to arrive and, if it does, accept it

Scripted Communication Rules

For a scripted class to be valid as the basis for a comms module, the following rules must apply:

  1. the primary interface (ie. interface number 0) must support the following properties:

    nametype
    log Log
    stack CommsStack

  2. the primary interface (ie. interface number 0) must support one or more of the following methods:

    nameargument typesreturn type
    connect none empty List ()
    send Buffer Object
    receive Integer Object
    receiveInto Buffer, Integer empty List ()
    connect none empty List ()
    bind none empty List ()
    listen Integer empty List ()
    accept Integer CommsModule

Notes:

  1. The reason for allowing the send method to return a value is that submission of a message to a message transfer service may result in a message id being passed back.
  2. A scripted modules is most often used as the top layer on the stack. If such a module is to be used lower down the stack, then the receiveInto method should be supplied in preference to the receive method.


Contents Index Current topic: communications Related topics: communications classes, objects