simpapp是Tuxedo系统自带的一个例子,它由服务器和客户程序两部分组成。服务器simpserv实现了一个TOUPPER服务,它从客户程序接收一个字符串,将它转换成大写后,传回客户端。
simpapp是Tuxedo系统自带的一个例子,它由服务器和客户程序两部分组成。服务器simpserv实现了一个TOUPPER服务,它从客户程序接收一个字符串,将它转换成大写后,传回客户端。
Tuxedo安装目录:D:tuxedo71
VC安装目录:C:Program FilesMicrosoft Visual StudioVC98
一、simpapp的服务程序:
#include <stdio.h>
#include <ctype.h>
#include <atmi.h>/* TUXEDO Header File */
#include <userlog.h>/* TUXEDO Header File */
#if defined(__STDC__) defined(__cplusplus)
tpsvrinit(int argc, char *argv[])
#else
tpsvrinit(argc, argv)
int argc;
char **argv;
#endif
{
/* Some compilers warn if argc and argv aren't used. */
argc = argc;
argv = argv;
/* userlog writes tothecentral TUXEDO message log */
userlog("Welcome to the simple server");
return(0);
}
#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) defined(__cplusplus)
TOUPPER(TPSVCINFO *rqst)
#else
TOUPPER(rqst)
TPSVCINFO *rqst;
#endif
{
int i;
for(i = 0; i < rqst->len-1; i++)
rqst->data[i] = toupper(rqst->data[i]);
/* Return the transformed buffer to the requestor. */
tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}
二、simpapp的客户程序:
/* #ident"@(#) apps/simpapp/simpcl.c$Revision: 1.1 $" */
#include <stdio.h>
#include "atmi.h"/* TUXEDOHeader File */
#if defined(__STDC__) defined(__cplusplus)
main(int argc, char *argv[])
#else
main(argc, argv)
int argc;
char *argv[];
#endif
{
char *sendbuf, *rcvbuf;
long sendlen, rcvlen;
int ret;
if(argc != 2) {
(void) fprintf(stderr, "Usage: simpcl stringn");
exit(1);
}
/* Attach to System/T as a Client Process */
if (tpinit((TPINIT *) NULL) == -1) {
(void) fprintf(stderr, "Tpinit failedn");
exit(1);
}
sendlen = strlen(argv[1]);
if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating send buffern");
tpterm();
exit(1);
}
if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating receive buffern");
tpfree(sendbuf);
tpterm();
exit(1);
}
(void) strcpy(sendbuf, argv[1]);
/* Request the service TOUPPER, waiting for a reply */
ret = tpcall("TOUPPER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);
if(ret == -1) {
(void) fprintf(stderr, "Can't send request to service TOUPPERn");
(void) fprintf(stderr, "Tperrno = %dn", tperrno);
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
exit(1);
}
(void) fprintf(stdout, "Returned string is: %sn", rcvbuf);
/* Free Buffers & Detach from System/T */
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
return(0);
}
三、simpapp的配置文件(ubbsimple):
*RESOURCES
IPCKEY123456
#Example:
#IPCKEY123456
DOMAINIDsimpapp
MASTERsimple
MAXACCESSERS10
MAXSERVERS5
MAXSERVICES10
MODELSHM
*MACHINES
DEFAULT:
APPDIR="D:tuxedo71samplesatmisimpapp"
TUXCONFIG="D:tuxedo71samplesatmisimpapptuxconfig"
TUXDIR="D:tuxedo71"
DUZRLMID=simple
*GROUPS
GROUP1
LMID=simpleGRPNO=1OPENINFO=NONE
*SERVERS
DEFAULT:
CLOPT="-A"
simpservSRVGRP=GROUP1 SRVID=1
*SERVICES
TOUPPER
四、simpapp的编译和运行:
1.设置环境变量:
Set TUXDIR=D:tuxedo71
Set WSNADDR=127.0.0.1:4444
Set APPDIR=D:tuxedo71samplesatmisimpapp
Set PATH=%TUXDIR%bin;%APPDIR%;%PATH%
Set TUXCONFIG=%APPDIR%tuxconfig
Set PATH=D:tuxedo71bin;
C:Program FilesMicrosoft Visual StudioVC98Include;
C:Program FilesMicrosoft Visual StudioVC98bin;
C:Program FilesMicrosoft Visual StudioCommonMSDev98Bin
(以上是配置Tuxedo使用VC的编译器)
2.生成二进制配置文件:
D:tuxedo71samplesatmisimpapp>tmloadcf ubbsimple
Really overwrite TUXCONFIG file: D:tuxedo71samplesatmisimpapptuxconfig [y,
q] ? y
3.编译客户端程序:
D:tuxedo71samplesatmisimpapp>buildclient -o simpcl.exe -f simpcl.c
结果:
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
simpcl.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:simpcl.exe
-implib:BC-628.lib
simpcl.obj
d:tuxedo71liblibtux.lib
d:tuxedo71liblibbuft.lib
d:tuxedo71liblibfml.lib
d:tuxedo71liblibfml32.lib
d:tuxedo71liblibengine.lib
wsock32.lib
kernel32.lib
advapi32.lib
user32.lib
gdi32.lib
comdlg32.lib
winspool.lib
4.编译服务程序:
D:tuxedo71samplesatmisimpapp>buildserver -o simpserv.exe -f simpserv.c -s TOUPPER
结果:
CMDTUX_CAT:4188: WARN: server built without the -s option cannot advertise servi
ces.
cl /MD-I"%TUXDIR%"include -Fesimpserv.exe BS-398.c simpserv.c"%TUXDIR%"lib
libtux.lib"%TUXDIR%"liblibbuft.lib"%TUXDIR%"liblibfml.lib "%TUXDIR%"l
iblibfml32.lib "%TUXDIR%"liblibengine.libwsock32.lib kernel32.lib advapi32.
lib user32.lib gdi32.lib comdlg32.lib winspool.lib-link -implib:BS-398.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
BS-398.c
simpserv.c
Generating Code...
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:simpserv.exe
-implib:BS-398.lib
BS-398.obj
simpserv.obj
d:tuxedo71liblibtux.lib
d:tuxedo71liblibbuft.lib
d:tuxedo71liblibfml.lib
d:tuxedo71liblibfml32.lib
d:tuxedo71liblibengine.lib
wsock32.lib
kernel32.lib
advapi32.lib
user32.lib
gdi32.lib
comdlg32.lib
winspool.lib
5.启动服务程序:
D:tuxedo71samplesatmisimpapp>tmboot -y
结果:
Booting all admin and server processes in D:tuxedo71samplesatmisimpapptuxco
nfig
INFO: BEA Engine, Version 7.1
INFO: Serial #: 78968, Expiration NONE, Maxusers 5
INFO: Licensed to: Hellongjiang Unicom
Booting admin processes ...
exec BBL -A :
process id=652 ... Started.
Booting server processes ...
exec simpserv -A :
process id=1864 ... Started.
2 processes started.
6.运行客户程序:
D:tuxedo71samplesatmisimpapp>simpcl dssdgdfg
结果:
Returned string is: DSSDGDFG
7.关闭服务应用程序:
D:tuxedo71samplesatmisimpapp>tmshutdown -y
结果:
Shutting down all admin and server processes in D:tuxedo71samplesatmisimpapp
tuxconfig
Shutting down server processes ...
Server Id = 1 Group Id = GROUP1 Machine = simple:shutdown succeed
ed
Shutting down admin processes ...
Server Id = 0 Group Id = simple Machine = simple:shutdown succeed
ed
2 processes stopped.
8.管理