Tuxedo 入门 C++Builder下的Sample

一、配置文件


# (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
IPCKEY 123456

#Example:
#IPCKEY 123456

DOMAINID simpapp
MASTER simple
MAXACCESSERS 10
MAXSERVERS 5
MAXSERVICES 10
MODEL SHM
LDBAL N

*MACHINES
DEFAULT:
APPDIR="D:\temp"
TUXCONFIG="D:\temp\tuxconfig"
TUXDIR="C:\bea\tuxedo8.1"
#Example:
# APPDIR="/home/me/simpapp"
# TUXCONFIG="/home/me/simpapp/tuxconfig"
# TUXDIR="/usr/tuxedo"

WANGZHIPC LMID=simple
MAXWSCLIENTS=5
ULOGPFX="D:\temp\ULOG"

#Example:
#beatux LMID=simple

*GROUPS
GROUP1
LMID=simple GRPNO=1 OPENINFO=NONE

#GROUP2
# LMID=simple GRPNO=2 OPENINFO=NONE

*SERVERS
DEFAULT:
CLOPT="-A"

simpserv SRVGRP=GROUP1 SRVID=1
WSL SRVGRP=GROUP1 SRVID=2 CLOPT="-A -- -n //127.0.0.1:3050 -m2 -M5 -x10"
*SERVICES
TOUPPER



二、 代码

/************************************************************
Copyright (C), 2001-2008, Multimedia Vision. Co., Ltd.
FileName: ConvertMess.cpp
Author: Wangzhi
Date: 2008-01-10
Description:
Tuxedo 测试,基于simple app 修改,C++ Builder 6
Version:
Function List:

History:
<author> <time> <version> <desc>
Wangzhi 2008/1/10 1.0 build this moudle
***********************************************************/

#include <vcl.h>

#include <atmi.h> /* TUXEDO Header File */
#include <fml32.h> /* TUXEDO Header File */
#include <tmenv.h> /* TUXEDO Header File */

#pragma hdrstop

#include "ConvertMess.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TConvertMessForm *ConvertMessForm;
//---------------------------------------------------------------------------
__fastcall TConvertMessForm::TConvertMessForm(TComponent* Owner)
: TForm(Owner)
{

}
//---------------------------------------------------------------------------


void __fastcall TConvertMessForm::butConvertClick(TObject *Sender)
{
char* sendBuffer; // 发送数据缓冲区
char* recvBuffer; // 接收数据缓冲区
long sendBufLength; // 发送数据长度
long recvBufLength; // 接收数据长度

int iRet; // 返回码

ShowErrorMessage("Werrer");

// 设置环境变量
tuxputenv("WSNADDR=//127.0.0.1:3050");

// 连接系统
if( -1 == tpinit((TPINIT *) NULL) )
{
ShowErrorMessage(tpstrerror(tperrno));
return;
}

// 计算发送缓冲长度
sendBufLength = strlen(txtMess->Text.c_str());

// 分配发送数据缓冲内存
sendBuffer = (char *) tpalloc("STRING", NULL, sendBufLength + 1);

if( NULL == sendBuffer) {
ShowErrorMessage("Alloc Send Buffer Memory Failed!!");
tpterm();
return;
}

// 分配接收数据缓冲内存
recvBuffer = (char *) tpalloc("STRING", NULL, sendBufLength + 1);

if( NULL == recvBuffer)
{
ShowErrorMessage("Alloc Recive Buffer Memory Failed!!");
tpfree(sendBuffer);
tpterm();
return;
}

// 把要发送的数据放入缓冲区
StrCopy(sendBuffer, txtMess->Text.c_str());

// 调用服务
iRet = tpcall("TOUPPER", (char *)sendBuffer, 0, (char **)&recvBuffer,
&recvBufLength, 0);

// 判断返回值,-1 为调用失败
if( -1 == iRet)
{
ShowErrorMessage(tpstrerror(tperrno));
tpfree(sendBuffer);
tpfree(recvBuffer);
tpterm();
}
else
{
txtConvert->Text = StrPas(recvBuffer);
tpfree(sendBuffer);
tpfree(recvBuffer);
tpterm();
}
}
//---------------------------------------------------------------------------

void TConvertMessForm::ShowErrorMessage(char * errMess)
{
lblNotice->Caption = errMess;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值