Tuxedo development in Windows

Source: Internet
Author: User
  1. Install
    Install tuxedo8.1 on winxpand copy it to the D:/BEA/tuxedo8.1/udataobj directory with the name licensefile named lic.txt. Select the license directory.
    Copied to the udataobj directory.
    [BEA Tuxedo]
    Developers = 5
    Licensee = China CNC
    Serial = 650522264138-1511336328750
    Type = SDK
    Users = 5
    Version = 8.1
    Signature = mc4cfqcugab0mfiqj6piucnjz5tmpha2waivalz6su + zhptrmmnxf0ofu9rpt3gs

    [Link encryption]
    Developers = 5
    Licensee = China CNC
    Serial = 650522264138-1511336328750
    Strength = 56
    Type = SDK
    Users = 5
    Version = 8.1
    Signature = mc0cfdo0wo + lr5jfjkoq5vglncrmfvuyahuarx + klwb6qrfewujsmns5p3gmvb4 =

    [PK encryption]
    Developers = 5
    Licensee = China CNC
    Serial = 650522264138-1511336328750
    Strength = 56
    Type = SDK
    Users = 5
    Version = 8.1
    Signature = mc0cfariv6cffzhh9cquziwbaznhfq8vahuas/k962upbb1mxrgw7clbmz88ejs =

    [PK signature]
    Developers = 5
    Licensee = China CNC
    Serial = 650522264138-1511336328750
    Strength = 56
    Type = SDK
    Users = 5
    Version = 8.1
    Signature = mcwcfbm04mn7qziqyfjbnudzvp78dpxpahrfzqq4bvln1/3knann8g7l/mjuww =

    [SNMP]
    Developers = 5
    Licensee = China CNC
    Serial = 650522264138-1511336328750
    Type = SDK
    Users = 5
    Version = 8.1
    Signature = mc0cfbm04mn7qziqyfjbnudzvp78dpxpahuanlizmimgzbsnv4yjn1cii/wha3c =

    [SSL encryption]
    Developers = 5
    Licensee = China CNC
    Serial = 650522264138-1511336328750
    Strength = 56
    Type = SDK
    Users = 5
    Version = 8.1
    Signature = mc0cfbm04mn7qziqyfjbnudzvp78dpxpahuayhg9ufcabk + doinluu + cgbujvyc =

  2. Set Environment Variables
    Modify the environment path and the executable file path of tuxedo. D:/BEA/tuxedo8.1/bin
    Tuxdir = D:/BEA/tuxedo8.1
    Tuxconfig = % appdir %/tuxconfig
  3. Compile the setenv. CMD script
    The content of setenv. CMD is as follows. After editing, it is stored in the D:/BEA/tuxedo8.1/apps/simpapp directory.
    Set tuxdir = D:/BEA/tuxedo8.1
    Set appdir = D:/BEA/tuxedo8.1/apps/simpapp
    Set Path = % tuxdir %/bin; % appdir %; % PATH %
    Set tuxconfig = % appdir %/tuxconfig
    Vcvars32.bat
    The preceding directory is modified according to your own situation.
  4. Edit ubbconfig
    Compile the file UBB and store it in the Directory D:/BEA/tuxedo8.1/apps/simpapp. The content is as follows:
    # (C) 2003 BEA Systems, Inc. All rights reserved.
    # Ident "@ (#) samples/atmi/simpapp/ubbsimple $ revision: 1.5 $"
    # Skeleton ubbconfig file for the tuxedo simple application.
    # Replace the <bracketed> items with the appropriate values.
    * Resources
    # Example:
    Ipckey 123456
    Domainid Chenli
    Master Chenli
    Maxaccessers 50
    Maxservers 5
    Maxservices 10
    Maxgtt 5
    Model SHM
    Ldbal n
    * Machines
    Default:
    Appdir = "D:/BEA/tuxedo8.1/apps/simpapp"
    Tuxconfig = "D:/BEA/tuxedo8.1/apps/simpapp/tuxconfig"
    Tuxdir = "D:/BEA/tuxedo8.1"
    Ulogpfx = "D:/BEA/tuxedo8.1/apps/simpapp/log.txt"
    Maxwsclients = 40
    # Example:
    # Appdir = "/home/ME/simpapp"
    # Tuxconfig = "/home/ME/simpapp/tuxconfig"
    # Tuxdir = "/usr/tuxedo"
    # <Machine-Name>
    Chenli lmid = Chenli
    # Example:
    # Beatux lmid = Chenli
    * Groups
    Group1 lmid = Chenli kgno = 1 openinfo = none

    * Servers
    Default:
    Clopt = "-"
    Simpserv srvgrp = group1 srvid = 1 min = 1 max = 5

    * Services
    Toupper

  5. Compile UBB
    Run the CMD command to go to the console and enter the D:/BEA/tuxedo8.1/apps/simpapp directory:
    Run the setenv command successively and run the script setenv. CMD edited above.
    Then run tmloadcf-y UBB to compile the UBB file.
    If any compilation error occurs, modify UBB according to the error information to solve the problem.
  6. Programming preparation
    A data. h header file needs to be used in subsequent programs and stored in the D:/BEA/tuxedo8.1/apps/simpapp directory. The content is as follows:

    # Ifndef data_h
    # Define data_h
    # Define name_length 64
    Typedef struct trans_data
    {
    Int age;
    Char name [name_length];
    } Trans_data_t;
    # Endif

  7. Write the server-side program simpserv. C.
    Edit the simpserv. c file and store it in the D:/BEA/tuxedo8.1/apps/simpapp directory. The content is as follows:
    /* (C) 2003 BEA Systems, Inc. All Rights Reserved .*/
    /* Copyright (c) 1997 BEA Systems, Inc.
    All Rights Reserved
    This is unpublished proprietary
    Source code of BEA Systems, Inc.
    The copyright notice above does not
    Evisponany actual or intended
    Publication of such source code.
    */
    /* # Ident "@ (#) samples/atmi/simpapp/simpserv. C $ revision: 1.5 $ "*/
    # Include <stdio. h>
    # Include <ctype. h>
    # Include <atmi. h>/* tuxedo header file */
    # Include <userlog. h>/* tuxedo header file */
    # Include "data. H"

    /* 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.
    */
    Int inc_count = 0;
    # If defined (_ stdc _) | defined (_ cplusplus)
    Tpsvrinit (INT argc, char * argv [])
    # Else
    Tpsvrinit (argc, argv)
    Int argc;
    Char ** argv;
    # Endif
    {
    /* Some compilation systems without argc and argv will have warning information .*/
    /* Some compilers warn if argc and argv aren't used .*/
    Argc = argc;
    Argv = argv;
    /* Userlog writes the tuxedo message to the log file */
    /* Userlog writes to the central tuxedo message log */
    Userlog ("welcome to the simple server ");
    Return (0 );
    }
    /* 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.
    */
    # Ifdef _ cplusplus
    Extern "C"
    # Endif
    Void
    # If defined (_ stdc _) | defined (_ cplusplus)
    Toupper (tpsvcinfo * rqst)/* tuxedo service name toupper */
    # Else
    Toupper (rqst)
    Tpsvcinfo * rqst;
    # Endif
    {
    Int I;
    Int X;
     
    Trans_data_t buf_data;
    Char * Data = "how are you? ";
    Char * ref;
    Int Len = strlen (data) + 1;
     
    Userlog ("START proccess toupper service ");
     
    Ref = (char *) malloc (LEN );
     
    Strcpy (ref, data );
     
    Userlog ("rqst-> Len = % d/N", rqst-> Len );
     
    Memcpy (& buf_data, rqst-> data, sizeof (trans_data_t ));

    Userlog ("receive string: % s", rqst-> data );
     
    Userlog ("receive name: % s", buf_data.name );
    Userlog ("receive age: % d", buf_data.age );
     
    Buf_data.age ++ = 100;
     
    Memcpy (rqst-> data, & buf_data, sizeof (trans_data_t ));
     
    // Data = rqst-> data;
     
    /* Return the transformed buffer to the requestor .*/
    /* Set the return Client Buffer */
    Tpreturn (tpsuccess, 0, rqst-> data, sizeof (trans_data_t), 0 );
     
    Free (REF );
    }

    Then run the command buildserver-O simpserv-F simpserv. C-s toupper on the console to compile the server program.

  8. Edit the client program simpcl. c
    Edit the simpcl. c file and save it to the D:/BEA/tuxedo8.1/apps/simpapp directory. The content is as follows:
    /* (C) 2003 BEA Systems, Inc. All Rights Reserved .*/
    /* Copyright (c) 1997 BEA Systems, Inc.
    All Rights Reserved
    This is unpublished proprietary
    Source code of BEA Systems, Inc.
    The copyright notice above does not
    Evisponany actual or intended
    Publication of such source code.
    */
    /* # Ident "@ (#) samples/atmi/simpapp/simpcl. C $ revision: 1.5 $ "*/
    # Include <stdio. h>
    # Include "atmi. H"/* tuxedo header file */
    # Include "data. H"
    # If defined (_ stdc _) | defined (_ cplusplus)
    Main (INT argc, char * argv [])
    # Else
    Main (argc, argv)
    Int argc;
    Char * argv [];
    # Endif
    {
    Trans_data_t buf_data;
    Char * sendbuf, * rcvbuf;
    Long sendlen, rcvlen;
    Int ret = 0;
    If (argc! = 2 ){
    (Void) fprintf (stderr, "Usage: simpcl age (INT)/n ");
    Exit (1 );
    }
     
    Buf_data.age = atoi (argv [1]);
    /* Connect to the tuxedo system as the tuxedo client */
    /* Attach to system/T as a client process */
    If (tpinit *) null) =-1 ){
    (Void) fprintf (stderr, "tpinit failed/N ");
    Exit (1 );
    }
     
    Sendlen = sizeof (trans_data_t );
    Strcpy (buf_data.name, "Chenli ");
    // Buf_data.age = 20;
     
    // Sendlen = strlen (argv [1]);
    /* Allocate string buffers for the request and the reply */
    /* Use tpalloc to apply for a string-type buffer as the request and Response Buffer */
    If (sendbuf = (char *) tpalloc ("carray", null, sendlen + 1) = NULL ){
    (Void) fprintf (stderr, "error allocating send buffer/N ");
    Tpterm ();
    Exit (1 );
    }

    If (rcvbuf = (char *) tpalloc ("carray", null, sendlen) = NULL ){
    (Void) fprintf (stderr, "error allocating Receive Buffer/N ");
    Tpfree (sendbuf );
    Tpterm ();
    Exit (1 );
    }
     
    Printf ("sendlen = % d/N", sendlen );
     
    Memcpy (sendbuf, & buf_data, sendlen );
    // (Void) strcpy (sendbuf, argv [1]);
     
    /* Request the service toupper, waiting for a reply */
    Ret = tpcall ("toupper", (char *) sendbuf, sendlen, (char **) & rcvbuf, & rcvlen, (long) 0 );
     
    (Void) fprintf (stderr, "RET value = % d/N", RET );
    /* Synchronously call the toupper Service */
    If (Ret <0 ){
    Printf ("tpcall failed, tperrno = % lD, tperrtext = % s/n", tperrno, tpstrerror (tperrno ));
    (Void) fprintf (stderr, "can't send request to service toupper/N ");
    (Void) fprintf (stderr, "tperrno = % d/N", tperrno );
    (Void) fprintf (stderr, "RET value = % d/N", RET );
    Tpfree (sendbuf );
    Tpfree (rcvbuf );
    Tpterm ();
    Exit (1 );
    }
     
    Memset (& buf_data, 0, sizeof (trans_data_t ));
     
    Memcpy (& buf_data, rcvbuf, rcvlen );
     
    Printf ("rcvlen = % d/N", rcvlen );
    (Void) fprintf (stdout, "returned name: % s/n", buf_data.name );
    (Void) fprintf (stdout, "returned age: % d/N", buf_data.age );
    /* Use tpfree to release the requested buffer space and respond to it */
    /* Free buffers & detach from system/T */
    Tpfree (sendbuf );
    Tpfree (rcvbuf );
    /* Use tpterm to exit tuxedo system */
    Tpterm ();
    Return (0 );
    }

    Run the buildclient-v-o client-F simpcl. C command in the directory where the file is located.

  9. Run and Test
    Run the tmboot-y command to start the tuxedo service.
    Run clien 1 in the command line to check whether any result is returned.
    Both client and server programs are simple. I believe you can understand them at a glance.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.