|
| iMatix home page | << | < | > | >> |
SMTVersion 2.81 |
#include "smtdefn.h" int smttran_init (void)
Initialises the SMT transfer agent. Returns 0 if initialised okay, -1 if there was an error. The transfer agent reads and writes blocks of data, or complete files, through an open TCP/IP socket. A block of data is sent/received as a two-byte length header followed by the data block. Creates an unnamed thread automatically. Supports these public methods:
| PUT BLOCK | Write a length-specified block to a socket (< 64k) |
| GET BLOCK | Read a length-specified block from a socket (< 64k) |
| PUT HUGE | Write a length-specified block to a socket (< 2Gb) |
| GET HUGE | Read a length-specified block from a socket (< 2Gb) |
| PUT FILE | Write part or all of a file to a socket |
| GET FILE | Read part or all of a file from a socket |
| PIPE CREATE | Create new transfer pipe |
| CLEAR PIPES | Destroy all transfer pipes |
| COMMIT | Wait until all transfer requests are finished |
{
AGENT *agent; /* Handle for our agent */
THREAD *thread; /* Handle to various threads */
# include "smttran.i" /* Include dialog interpreter */
/* Method name Event value Priority */
/* Shutdown event comes from Kernel */
method declare (agent, "SHUTDOWN", shutdown_event, SMT_PRIORITY_MAX);
/* Reply events from socket agent */
method declare (agent, "SOCK_INPUT_OK", ok_event, 0);
method declare (agent, "SOCK_OUTPUT_OK", ok_event, 0);
method declare (agent, "SOCK_READ_OK", read_ok_event, 0);
method declare (agent, "SOCK_WRITE_OK", write_ok_event, 0);
method declare (agent, "SOCK_READH_OK", readh_ok_event, 0);
method declare (agent, "SOCK_WRITEH_OK", writeh_ok_event, 0);
method declare (agent, "SOCK_CLOSED", sock_closed_event, 0);
method declare (agent, "SOCK_ERROR", sock_error_event, 0);
method declare (agent, "SOCK_TIMEOUT", sock_error_event, 0);
/* Reply events from timer agent */
method declare (agent, "TIME_ALARM", alarm_event, 0);
method declare (agent, "TIME_ERROR", error_event, 0);
/* Public methods supported by this agent */
declare_put_block (put_block_event, 0);
declare_get_block (get_block_event, 0);
declare_put_huge (put_huge_event, 0);
declare_get_huge (get_huge_event, 0);
declare_put_file (put_file_event, 0);
declare_get_file (get_file_event, 0);
declare_pipe_create (pipe_create_event, 0);
declare_clear_pipes (clear_pipes_event, 0);
declare_tran_commit (commit_event, SMT_PRIORITY_MIN);
/* Private methods used to pass initial thread events */
method declare (agent, "_MASTER", master_event, 0);
method declare (agent, "_PIPE_MANAGER", pipe_manager_event, 0);
/* Ensure that operator console is running, else start it up */
smtoper init ();
if ((thread = thread lookup (SMT_OPERATOR, "")) != NULL)
operq = thread-> queue-> qid;
else
return (-1);
/* Ensure that socket agent is running, else start it up */
smtsock init ();
if ((thread = thread lookup (SMT_SOCKET, "")) != NULL)
sockq = thread-> queue-> qid;
else
return (-1);
/* Ensure that timer agent is running, else start it up */
smttime init ();
if ((thread = thread lookup (SMT_TIMER, "")) != NULL)
timeq = thread-> queue-> qid;
else
return (-1);
/* Create initial thread to manage master thread */
if ((thread = thread create (AGENT_NAME, "")) != NULL)
{
SEND (&thread-> queue-> qid, "_MASTER", "");
((TCB *) thread-> tcb)-> thread_type = master_event;
((TCB *) thread-> tcb)-> filename = NULL;
}
else
return (-1);
/* Create initial thread to manage pipes */
if ((thread = thread create (AGENT_NAME, "__pipe_manager")) != NULL)
{
SEND (&thread-> queue-> qid, "_PIPE_MANAGER", "");
((TCB *) thread-> tcb)-> thread_type = pipe_manager_event;
((TCB *) thread-> tcb)-> filename = NULL;
}
else
return (-1);
/* Clear & prepare request queue */
node_reset (&requests);
/* Create pipe lookup table */
pipes = sym_create_table ();
/* Signal okay to caller that we initialised okay */
return (0);
}
| | << | < | > | >> |
|