| iMatix home page
| << | < | > | >>
SMT Logo SMT
Version 2.81

 

The Transfer Agent - SMTTRAN

Transfers blocks of data or files to connected sockets. You can use this agent to simplify certain types of communication. The transfer agent uses the socket agent for actual reading and writing to sockets.

To use SMTTRAN, call smttran init(). This creates a single unnamed thread automatically the first time it is called, and has no effect thereafter. You can then send messages to this thread. It supports these methods:

Example of initialising SMTTRAN:

/*  Static data                                                 */
static QID
    tranq;                      /*  Transfer agent queue        */

    /*  In agent initialisation code                            */
    THREAD  *thread;            /*  Handle to console thread    */
    /*  Ensure that transfer agent is running, else start it    */
    smttran init ();
    if ((thread = thread lookup (SMT_TRANSFER, "")) != NULL)
        tranq = thread-> queue-> qid;
    else
        return (-1);

The PUT_BLOCK Method

Writes a length-specified block to a socket: first writes a two-byte length specifier in network format, then writes the block data. Build the event body using exdr_write() and the message definition SMT_TRAN_PUTB. The event body consists of these fields (see exdr_write() for the field types):

SMTTRAN replies to a PUT_BLOCK event with one of these events:

The GET_BLOCK Method

Reads a length-specified block from a socket: first reads a two-byte length specifier in network format, then reads that many bytes of block data. Build the event body using exdr_write() and the message definition SMT_TRAN_GETB. The event body consists of these fields (see exdr_write() for the field types):

SMTTRAN replies to a GET_BLOCK event with one of these events:

The PUT_FILE Method

Writes a file to a socket: reads the file in pieces of unspecified size, and writes these to the output socket. Build the event body using exdr_write() and the message definition SMT_TRAN_PUTF. The event body consists of these fields (see exdr_write() for the field types):

SMTTRAN replies to a PUT_FILE event with one of these events:

The GET_FILE Method

Reads a file from a socket and saves it with the specified name. Build the event body using exdr_write() and the message definition SMT_TRAN_GETF. The event body consists of these fields (see exdr_write() for the field types):

SMTTRAN replies to a GET_FILE event with one of these events:

The COMMIT Method

Waits until all put and get requests are finished, then replies with a TRAN_CLOSED event. This event does not take any arguments. SMTTRAN replies to a GET_FILE event with one of these events:

Example Of Use

The SMTHTTP agent uses the transfer agent to send files.

SMTTRAN Implementation

The hypertext view of SMTTRAN's dialog and source code may help to understand how SMTTRAN works.


| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation