BEA Logo BEA Tuxedo Release 8.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Tuxedo Documentation   |   Tutorials for Developing BEA Tuxedo ATMI Applications   |   Local Topics   |   Previous Topic   |   Next Topic   |   Contents

 


Step 3: Examining and Compiling the Server

How to Examine the Server

Review the ATMI server program source code.

$ more simpserv.c

Source Code of simpserv.c

   */
/* #ident	"@(#) apps/simpapp/simpserv.c	$Revision: 1.1 $" */
1 #include <stdio.h>
2 #include <ctype.h>
3 #include <atmi.h> /* TUXEDO Header File */
4 #include <userlog.h> /* TUXEDO Header File */
5 /* tpsvrinit is executed when a server is booted, before it begins
processing requests. It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.
9  */
10 #if defined(__STDC__) || defined(__cplusplus)

12 tpsvrinit(int argc, char *argv[])
13 #else
14 tpsvrinit(argc, argv)
15 int argc;
16 char **argv;
17 #endif
18 {
19 /* Some compilers warn if argc and argv aren't used.
20 */
21 argc = argc;
22 argv = argv;
23 /* userlog writes to the central TUXEDO message log */
24 userlog("Welcome to the simple server");
25 return(0);
26 }
27 /* This function performs the actual service requested by the client.
Its argument is a structure containing, among other things, a pointer
to the data buffer, and the length of the data buffer.
30 */
31 #ifdef __cplusplus
32 extern "C"
33 #endif
34 void
35 #if defined(__STDC__) || defined(__cplusplus)
36 TOUPPER(TPSVCINFO *rqst)
37 #else
38 TOUPPER(rqst)
39 TPSVCINFO *rqst;
40 #endif
41 {
42 int i;
43
44 for(i = 0; i < rqst->len-1; i++)
45 rqst->data[i] = toupper(rqst->data[i]);
46 /* Return the transformed buffer to the requestor. */
47 tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
48 }

Significant Parts of the simpserv.c Source Code

Line(s)

File/Function

Purpose

Whole file


A BEA Tuxedo server does not contain a main(). The main() is provided by the BEA Tuxedo system when the server is built.

12

tpsvrinit()

This subroutine is called during server initialization, that is, before the server begins processing service requests. A default subroutine (provided by the BEA Tuxedo system) writes a message to USERLOG indicating that the server has been booted. userlog(3c) is a log used by the BEA Tuxedo system and can be used by applications.

38

TOUPPER()

The declaration of a service (the only one offered by simpserv). The sole argument expected by the service is a pointer to a TPSVCINFO structure, which contains the data string to be converted to uppercase.

45

for loop

Converts the input to uppercase by repeated calls to TOUPPER.

49

tpreturn()

Returns the converted string to the client with the TPSUCCESS flag set.


 

How to Compile the Server

  1. Run buildserver to compile the ATMI server program:
        buildserver -o simpserv -f simpserv.c -s TOUPPER

    The executable file to be created is named simpserv and simpserv.c is the input source file. The -s TOUPPER option specifies the service to be advertised when the server is booted.

  2. Check the results:
    $ ls -l
    total 97
    -rwxr-x--x 1 usrid grpid 313091 May 28 15:41 simpcl
    -rw-r----- 1 usrid grpid 1064 May 28 07:51 simpcl.c
    -rwxr-x--x 1 usrid grpid 358369 May 29 09:00 simpserv
    -rw-r----- 1 usrid grpid 275 May 28 08:57 simpserv.c
    -rw-r----- 1 usrid grpid 392 May 28 07:51 ubbsimple

You now have an executable module called simpserv.

See Also

 

back to top previous page next page