- 论坛徽章:
- 0
|
求助tuxedo问题,急急急.
ubb配置
#file: ubbconfig
*RESOURCES
IPCKEY 50000
MASTER SITE1
MODEL SHM
MAXCONV 20
*MACHINES
KEVIN LMID=SITE1
TUXDIR = "D:\PROGRA~1\BEASYS~1\Tuxedo"
APPDIR = "d:\documents\products\tuxedo\quick start\lab\qs-14"
TUXCONFIG = "d:\documents\products\tuxedo\quick start\lab\qs-14\tuxconfig"
MAXCONV = 25
*GROUPS
GROUP1 LMID=SITE1 GRPNO=1
*SERVERS
simpserv SRVGRP=GROUP1 SRVID=1 CONV=Y
*SERVICES
CONVERS
服务端代码
#include <stdio.h>;
#include <ctype.h>;
#include "atmi.h"
#define SRECV 1
#define SSEND 2
#define SDONE 3
void
CONVERS(TPSVCINFO *rqst)
{
static state = SRECV;
long len, revent;
char *buf;
buf=tpalloc("STRING", NULL, 80);
for ( ; ; )
{
switch(state)
{
case SRECV:
if(tprecv(rqst->;cd, &buf, &len, 0, &revent )==-1)
{
if(tperrno == TPEEVENT && revent == TPEV_SENDONLY)
{
userlog("state change from receive to send" ;
state = SSEND;
}
else
{
tpreturn(TPFAIL, 0, rqst->;data, 0, 0);
}
}
userlog("tprecv(): %s", buf);
break;
case SSEND:
strcpy(buf, "all done & protocol complete" ;
if (tpsend(rqst->;cd, buf, 0, 0, &revent)== -1)
{
userlog("tpsend(%d): %s",
revent, tpstrerror(tperrno));
}
else
{
userlog("SENT MESSAGE" ;
}
state = SDONE;
break;
case SDONE:
tpfree(buf);
tpreturn(TPSUCCESS, 0, rqst->;data, 0, 0);
break;
}
}
}
客户端代码
#include <stdio.h>;
#include "atmi.h"
main(int argc, char *argv[])
{
int ret, cd; /* General loop counter */
char *buf; /* Pointer to buffer */
long len; /* Buf length */
long revent; /* Event type if tpsend fails */
/* Connect to TUXEDO - tpinit() */
if (tpinit((TPINIT *) NULL) == -1){
printf("Failed to join application\n" ;
exit(1);
}
if ((buf = (char *)tpalloc("STRING", NULL, 1024)) == NULL)
{
printf("tpalloc(): %s\n", tpstrerror(tperrno));
tpterm();
exit(-1);
}
if (cd = tpconnect("CONVERS", NULL, 0, TPSENDONLY) == -1)
{
printf("tpconnect(): %s\n", tpstrerror(tperrno));
tpfree(buf);
tpterm();
exit(-1);
}
strcpy(buf, "humpty dumpty" ;
if (tpsend(cd, buf, (long)strlen(buf), 0, &revent) == -1)
{
printf("tpsend(): %s\n", tpstrerror(tperrno));
}
strcpy(buf, "mickey mouse" ;
if (tpsend(cd, buf, (long)strlen(buf), 0, &revent) == -1)
{
printf("tpsend(): %s\n", tpstrerror(tperrno));
}
if (tpsend(cd, NULL, 0, TPRECVONLY, &revent) == -1)
{
printf("tpsend(): %s\n", tpstrerror(tperrno));
}
if (tprecv(cd, &buf, &len, 0, &revent) == -1)
{
printf("tprecv(): %s\n", tpstrerror(tperrno));
}
printf("recv\n" ;
printf("tprecv() %s\n", buf);
tpdiscon(cd);
tpfree(buf);
tpterm();
} |
|