下载此文档

tuxedo-客户端-服务器程序范例.doc


文档分类:IT计算机 | 页数:约11页 举报非法文档有奖
1/11
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/11 下载此文档
文档列表 文档介绍
Tpinit //传递客户认证信息
Tpalloc //申请缓冲区
Tpcall //调用服务
Tpfree//释放指向缓冲区的指针
Tpsvrinit//服务启动前的一个初始化
Tpsvrdone//关闭服务之前自动调用
Tpreturn //响应后返回信息
char *tpalloc(char *type,char *subtype,long size)
Type 用于指定缓冲区类型,可取值STRING FML XML等
Subtype 用于指定缓冲区子类型,仅在分配VIEW缓冲区时,指定对应的C结构名,对于其它缓冲区来说,填NULL
Size 是缓冲区大小,以字节为单位,如1024表示分配1KB缓冲区
Tpalloc 返还分配缓冲区的指针,返还NULL标识分配失败
void tpfree(char *ptr)
Ptr是要释放的缓冲区的指针
Tpfree没有返还值,也就是说不用判断它是否成功的释放了缓冲区
int tpcall(char *svc,char *idata,long ilen,char **odata,long *olen,long flags)
Svc 是要调用的服务名
Idata 是请求缓冲区指针,ilen是请求缓冲区长度
Odata 是指向响应缓冲区指针的指针,使用双重指针的目的是便于动态调整响应缓冲区的大小
Client:
/* (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
evidence any actual or intended
publication of such source code.
*/
/* #ident "@(#) samples/atmi/simpapp/ $Revision: $" */
#include <>
#include "" /* TUXEDO Header 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 string\n");
exit(1);
}
/* Attach to System/T as a Client Process */
//向服务器传递客户认证信息
if (tpinit((TPINIT *) NULL) == -1) {
(void) fprintf(stderr, "Tpinit failed\n");
exit(1);
}

sendlen = strlen(argv[1]);
/* Allocate STRING buffers for the request and the reply */
//分配缓冲区
if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}
if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating receive buffer\n");
tpfree(sendbuf);//释放指向缓冲区的指针
tpterm();
exit(1);
}
(void) strcpy(sendbuf, argv[1]);
/* Request the service TOUPPE

tuxedo-客户端-服务器程序范例 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数11
  • 收藏数0 收藏
  • 顶次数0
  • 上传人yixingmaoj
  • 文件大小372 KB
  • 时间2018-08-13