FTDOC.TXT

##############################################################################
#
#  Copyright (c) 1999 by
#  blaxxun interactive Inc, San Francisco, California, USA
#  All rights reserved
#
#  MODULE NAME:  $RCSfile: ftdoc.txt,v $
#  REVISION:     $Revision: 1.2 $
#  DATE:         $Date: 2000/03/29 04:22:22 $
#  AUTHOR:       $Author: peter $
#  STATE:        $State: Exp $
#
#  PROJECT:            BSI
#  SYSTEM:             server      - server processes
#  SUBSYSTEM:          ftserver    - file transfer
#
# $Log: ftdoc.txt,v $
# Revision 1.2  2000/03/29 04:22:22  peter
# added the server interface description
#
# Revision 1.1  1999/12/13 04:19:56  peter
# Initial revision
#
#
##############################################################################
#
#  FT - File Transfer Service 
#
#  ftdoc.txt - Documentation
# 

Table of Contents:
1. Overview

2. Files
2.1. ftsocket.c
2.2. ft.h
2.3. ftbase.c
2.4. ftevent.c
2.5. ftfetch.c
2.6. compress.c

3. Client API
3.1. Functions
3.1.1. ftTransInit
3.1.2. ftTransPeriodic
3.1.3. ftTransGetBuffer

4. CGI Script FTFetch

5. API Server Ftserver.
5.1. UNIX Process - ftserver
5.2. NT Service - ftserver.exe

6. Globals

1. Overview

contents

The File Transfer Service allows to transfer files from one machine running blaxxun Contact to another machine. This is roughly how it works.

2. Files

contents

2.1. ftsocket.c

contents

  PROJECT:            BSI
  SYSTEM:             server      - server processes
  SUBSYSTEM:          ftserver    - file transfer
  COMPONENT:          ftsocket    - client interface for file transfer

  DESCRIPTION:
      The interface to be linked into cybersockets.

2.2. ft.h

contents

  PROJECT:            BSI
  SYSTEM:             server      - server processes
  SUBSYSTEM:          ftserver    - file transfer service

  DESCRIPTION:
      Include file for file transfer service

2.3. ftbase.c

contents

  PROJECT:            BSI
  SYSTEM:             server      - server processes
  SUBSYSTEM:          ftserver    - file transfer server

  DESCRIPTION:
      Base functions used by server and cgi script.

2.4. ftevent.c

contents

  PROJECT:            BSI
  SYSTEM:             server      - server processes
  SUBSYSTEM:          ftserver    - file transfer server

  DESCRIPTION:
      Event functions called. The functions given in this file are
      the Event Functions of the API server ftserver.

2.5. ftfetch.c

contents

  PROJECT:            server
  COMPONENT:          ftserver - file transfer service

  DESCRIPTION:

   ftfetch - file transfer cgi program

2.6. compress.c

contents

  PROJECT:            server      - COMMUNITY SERVER
  SUBSYSTEM:          ftserver    - file transfer
  COMPONENT:          compress    - transfer compression, decompression routines

  DESCRIPTION:
      Compression, decompression routines for network traffic

3. Client API

contents

The client API of the file transfer service is called from the cybersockets layer of blaxxun Contact. The API functions are part of the WIN 32 library ivlib.lib. This library has to be linked into blaxxun Contact.

3.1. Functions

contents

3.1.1. ftTransInit

contents

------------------------------------------------------------------------------
  FUNCTION NAME:        ftTransInit

  DESCRIPTION:
    Initialize a file transfer, parse and adopt the show document url

    An url of the form

       ftfetch?FIL=filename

    is transfered to

       ftfetch?FID=fileid&CID=clientid

    where fileid is a 9 byte id for the file to be transfered
    and clientid is the idserver client id of the sender as 8 byte string.

    The first byte of the file id is
     U if the sender uses UDP
     T if the sender uses TCP
     H if the sender uses HTTP.

    The file has to reside in the directory "transfer".
    The file is read into heap memory by this function.

    File transfers time out after two minutes if the file
    is not fetched by the ftserver and after 3 minutes
    if the file is fetched.

  RETURN VALUES:
    int rc >  0: length of changed show document url to send
    int rc == 0: just send the inbuf as is
    int rc <  0: an error
------------------------------------------------------------------------------
*/
int ftTransInit(
int            protocol,     /* r: protocol used by client                  */
unsigned long  sessionid,    /* r: id of sender session                     */
const char   * installdir,   /* r: install directory of program             */
const char   * inbuf,        /* r: show document url given by application   */
size_t         inbuflen,     /* r: length of that url                       */
char         * outbuf,       /* w: buffer to write new url packet to        */
size_t         outbuflen     /* r: length of that buffer                    */
)

3.1.2. ftTransPeriodic

contents

------------------------------------------------------------------------------
  FUNCTION NAME:        ftTransPeriodic

  DESCRIPTION:
    Periodic handling of transfer service, clears buffer spaces of file
    transfers that have timed out

  RETURN VALUES:
    void
------------------------------------------------------------------------------
*/
void ftTransPeriodic()

3.1.3. ftTransGetBuffer

contents

------------------------------------------------------------------------------
  FUNCTION NAME:        ftTransGetBuffer

  DESCRIPTION:
    Get a buffer from a transfer file at a specific offset.
    This functions is called for each block fetch request sent
    by the ftserver.

  RETURN VALUES:
    int rc >  0: length of the buffer filled
    int rc == 0: the offset is out of range

------------------------------------------------------------------------------
*/
int ftTransGetBuffer(
unsigned long   fid,    /* r: file id of transfer file to read block for    */
unsigned long   offset, /* r: offset of block to read                       */
char          * buffer  /* w: buffer filled, must be FT_BUFFER_LENGTH bytes */
)

4. CGI Script FTFetch

contents

The CGI script is used by the receivers of the file transfer service in order to transfer the files to the receiver's web browser. ftfetch has to be installed into the csbin/community cgi directory of the Community Server installation.

------------------------------------------------------------------------------
  FUNCTION NAME:        main ftfetch

  DESCRIPTION:          The main of the ftfetch program.

    The script has to be installed into csbin/community.

    The scripts reads the variables g_FtServer and g_FtPort from
    global.cfg in order to find out which ftserver to contact.

     Example entries could be

     g_FtServer        localhost
     g_FtPort          2020

    The script reads the config file ./config/ftfetch.cfg in order
    to determine the mimetypes of files transfered from their 
    extensions.

     An example ftfetch.cfg file might be

     # ftfetch.cfg
     #
     # extension to mimetype mapping
     #
     htm    text/html
     html   text/html
     exe    application/octet-stream
     class  application/octet-stream
            
     jpeg   image/jpeg
     jpg    image/jpeg
     jpe    image/jpeg
     gif    image/gif

    The script reads the CGI parameters FID and CID in order to
    determine the ID of the file to fetch and the client id of
    the client to fetch the file from.

    The script uses raudp calls in order to fetch the blocks of the file
    to transfer one by one from the ftserver.

    The syntax of the raudp calls is:

     raudp FT <FID> <CID> <OFF>

     where 
         FID is the file id CGI parameter received
         CID is the client id CGI parameter received
         OFF is the offset of the block to fetch 

    Possible error conditions are.

    - Timeout while contacting the ftserver

    - Client id is unknown, the client to fetch the file from
      has left the scene

    - File id invalid, the client refuses to transfer the file

    - Timeout while transfering the file

------------------------------------------------------------------------------
*/
int main( int  argc, char *argv[] )

5. API Server Ftserver.

contents

The ftserver is an API server that handles the raudp file block fetch requests from the cgi script ftfetch and requests the blocks of the file from the cybersockets layer of the sending client.

The ftserver has to be added to the idsever configuration file in order to be recognized by the idserver and to be able to determine the IP address and port number of a client given by its clientid. The ftserver subscribes the User New Log and the User Left event of the idserver.

The following should be added to etc/idserver.cfg

# The following enables the ftserver
APISERVER          localhost:2020

The ftserver buffers the file during the request, thus if multiple clients fetch the file, the file is only requested once from the sending client.

If the sending client uses UDP the ftserver fetches FT_BLOCKS_PER_FETCH in each fetch request. If the client uses TCP or HTTP the ftserver requests the entire file at once from the client.

5.1. UNIX Process - ftserver

contents

The UNIX process ftserver has the following command line interface.


ftserver -p port -i idhost:idport -BSIROOT rootdir [ -TRACE ]

-p port is the port the fterver listens on -i idhost:idport is the host and port number of the idserver the ftserver sould connect to -BSIROOT rootdir install directory of blaxxun Community Server -TRACE turns on trace mode

5.2. NT Service - ftserver.exe

contents

All parameters of ftserver are read from the Windows NT Registry. The parameters are stored under LOCALMACHINE/SOFTWARE/blaxxuninteractive

The following values are stored there.

ftserverPort, see -p option above.
ftserverIdserverHostPort, see -i option above
InstallDirectory, see -BSIROOT option above.
ftserverTrace, if this option is set to on the -TRACE is activated.

6. Globals

contents

 */
/*
 * protocol specifiers used in the file id
 */
#define FT_PROTOCOL_UDP             'U'
#define FT_PROTOCOL_TCP             'T'
#define FT_PROTOCOL_HTTP            'H'

/*
 * size of the blocks fetched
 */
#define FT_BUFFER_LENGTH            512

/*
 * number of blocks fetched at once in the UDP case
 */
#define FT_BLOCKS_PER_FETCH           6


End of document!