免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7714 | 回复: 4
打印 上一主题 下一主题

[Tuxedo] 关于tuxedo客户端调用中tpconnect的问题。。。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-28 20:10 |只看该作者 |倒序浏览
请教一下,如何添充tpconnect函数调用中第一个参数?

    定义说第一个参数是指向会话模式服务名的指针,可我不知怎么用呀?请指教。

论坛徽章:
0
2 [报告]
发表于 2003-06-28 21:26 |只看该作者

关于tuxedo客户端调用中tpconnect的问题。。。

就是你的服务名。比如你的SERVER函数是TUXSERVER
参数写"TUXSERVER"就可以了

论坛徽章:
0
3 [报告]
发表于 2003-06-29 15:03 |只看该作者

关于tuxedo客户端调用中tpconnect的问题。。。

我是作客户端调用的,如何知道server端的服务名呢?

论坛徽章:
0
4 [报告]
发表于 2003-06-29 16:53 |只看该作者

关于tuxedo客户端调用中tpconnect的问题。。。

:)那服务端是谁写的?

论坛徽章:
0
5 [报告]
发表于 2003-06-29 20:02 |只看该作者

关于tuxedo客户端调用中tpconnect的问题。。。

[Top] [Prev] [Next] [Bottom]
--------------------------------------------------------------------------------


tpconnect(3)
Name
tpconnect-routine for establishing a conversational service connection

Synopsis
#include <atmi.h>;  int tpconnect(char *svc, char *data, long len, long flags)
Description
tpconnect() allows a program to set up a half-duplex connection to a conversational service, svc. The name must be one of the conversational service names posted by a conversational server.

As part of setting up a connection, the caller can pass application defined data to the listening program. If the caller chooses to pass data, then data must point to a buffer previously allocated by tpalloc(3). len specifies how much of the buffer to send. Note that if data points to a buffer of a type that does not require a length to be specified, (for example, an FML fielded buffer), then len is ignored (and may be 0). Also, data can be NULL in which case len is ignored (no application data is passed to the conversational service). The type and sub-type of data must match one of the types and sub-types recognized by svc. data and len are passed to the conversational service via the TPSVCINFO structure with which the service is invoked; the service does not have to call tprecv(3) to get the data.

Following is a list of valid flags.


TPNOTRAN
If the caller is in transaction mode and this flag is set, then when svc is invoked, it is not performed on behalf of the caller's transaction. Note that svc may still be invoked in transaction mode but it will not be the same transaction: a svc may have as a configuration attribute that it is automatically invoked in transaction mode. A caller in transaction mode that sets this flag is still subject to the transaction timeout (and no other). If a service fails that was invoked with this flag, the caller's transaction is not affected.

TPSENDONLY
The caller wants the connection to be set up initially such that it can only send data and the called service can only receive data (that is, the caller initially has control of the connection). Either TPSENDONLY or TPRECVONLY must be specified.

TPRECVONLY
The caller wants the connection to be set up initially such that it can only receive data and the called service can only send data (that is, the service being called initially has control of the connection). Either TPSENDONLY or TPRECVONLY must be specified.

TPNOBLOCK
The connection is not established and the data is not sent if a blocking condition exists (for example, the data buffers through which the message is sent are full). Note that this flag applies only to the send portion of tpconnect(); the function may block waiting for an acknowledgement from the server. When TPNOBLOCK is not specified and a blocking condition exists, the caller blocks until the condition subsides or a blocking timeout or transaction timeout occurs.

TPNOTIME
This flag signifies that the caller is willing to block indefinitely and wants to be immune to blocking timeouts. Transaction timeouts will still affect the program.

TPSIGRSTRT
If a signal interrupts any underlying system calls, then the interrupted call is re-issued.
Return Values
Upon successful completion, tpconnect() returns a descriptor that is used to refer to the connection in subsequent calls. Otherwise it returns \-1 and sets tperrno to indicate the error condition.

Errors
Under the following conditions, tpconnect() fails and sets tperrno to an error code listed below. (Unless otherwise noted, failure does not affect the caller's transaction, if one exists)


[TPEINVAL]
Invalid arguments were given (for example, svc is NULL, data is non-NULL and does not point to a buffer allocated by tpalloc(3), TPSENDONLY or TPRECVONLY was not specified in flags, or flags are otherwise invalid).

[TPENOENT]
Cannot initiate a connection to svc because it does not exist or is not a conversational service.

[TPEITYPE]
The type and subtype of data is not one of the allowed types and subtypes that svc accepts.

[TPELIMIT]
The caller's request was not sent because the maximum number of outstanding connections has been reached.

[TPETRAN]
svc belongs to a program that does not support transactions and TPNOTRAN was not set.

[TPETIME]
A timeout occurred. If the caller is in transaction mode, then a transaction timeout occurred and the transaction is marked abort-only; otherwise, a blocking timeout occurred and neither TPNOBLOCK nor TPNOTIME were specified. If a transaction timeout occurred, then any attempts to send or receive messages on any connections or to start a new connection will fail with TPETIME until the transaction has been aborted.

[TPEBLOCK]
A blocking condition exists and TPNOBLOCK was specified.

[TPGOTSIG]
A signal was received and TPSIGRSTRT was not specified.

[TPEPROTO]
tpconnect() was called in an improper context.

[TPESYSTEM]
A BEA TUXEDO system error has occurred. The exact nature of the error is written to a log file.

[TPEOS]
An operating system error has occurred.
See Also
tpalloc(3), tpdiscon(3), tprecv(3), tpsend(3), tpservice(3)


--------------------------------------------------------------------------------

[Top] [Prev] [Next] [Bottom]
--------------------------------------------------------------------------------


/*        Copyright (c) 1998 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.
*/

/*        Copyright 1996 BEA Systems, Inc.        */
/*        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.        */

/*        Copyright (c) 1991 Unix System Laboratories, Inc.
        All rights reserved

        THIS IS UNPUBLISHED PROPRIETARY
        SOURCE CODE OF Unix System Laboratories, Inc.
        The copyright notice above does not
        evidence any actual or intended
        publication of such source code.
*/
/* #ident        "@(#) apps/bankapp/auditcon.c        $Revision: 1.1 $" */

#ifndef NOWHAT
static        char        sccsid[] = "@(#) apps/bankapp/auditcon.c        $Revision: 1.1 $";
#endif

/*
* auditcon is a client program which interactively finds the total balance
* of all the accounts/tellers at a branch or the total for the entire bank,
* using conversations. functionaly, auditcon is similiar to audit.
*/

#include <stdio.h>;                /* UNIX */
#include <string.h>;                /* UNIX */
#include <atmi.h>;                /* TUXEDO */
#include <Uunix.h>;                /* TUXEDO */
#include <userlog.h>;                /* TUXEDO */

#define        LINE        80                /* size of reply line        */

#ifdef WIN32
extern char *getpass _((const char *prompt));
#endif


/* ARGSUSED */

#if defined(__STDC__) || defined(__cplusplus)
main(int argc, char *argv[])
#else
main(argc, argv)
int argc;
char *argv[];
#endif

{
        int cd;                        /* conversation descriptor        */
        char *line;                /* tux buffer holding reply        */
        char reply[LINE+1];        /* reply line */
        long len;                /* length of recv'd line        */
        long revent;                /* events for send/recv        */

        TPINIT *tpinitbuf ;        /* for client identification */
        int        auth ;                /* to hold value of tpchkauth() */
        char        *passwd ;        /* passwd obtained from user */

        if (strrchr(argv[0],'/') != NULL)
                proc_name = strrchr(argv[0],'/')+1;
        else
                proc_name = argv[0];

        /*
         * Alloc a TPINIT buffer for identification purposes
         * This is not mandatory if no authentication is configured
         */

        tpinitbuf = (TPINIT *) tpalloc("TPINIT", NULL, TPINITNEED(16)) ;

        if (tpinitbuf == (TPINIT *) NULL) {
                (void)fprintf(stderr, "Failed for TPINIT buffer, %s\n",
                        tpstrerror(tperrno));
                (void)userlog("Failed for TPINIT buffer, %s",
                        tpstrerror(tperrno));
                exit(1);
        }

        /*
         * Check the type of authentication the application is configured
         * for and populate TPINIT buffer with authentication info.
         */

        switch (auth = tpchkauth()) {
            case TPNOAUTH :
                    (void)strcpy (tpinitbuf->;usrname, argv[0]) ;
                    (void)strcpy (tpinitbuf->;passwd, "" ;
                    break ;

            case TPSYSAUTH :
            case TPAPPAUTH :
                    /* request for the application password */

                    if ((passwd = getpass("Application Password:") == NULL) {
                        (void)userlog ("ERROR: Unable to get Application Password";
                        exit(3) ;
                    }
                    (void)strcpy (tpinitbuf->;passwd, passwd) ;

                    if (auth == TPSYSAUTH)
                        break ;

                    /* request for the user name and user's password */

                    (void)printf ("User Name:" ;
                    (void)gets (tpinitbuf->;usrname) ;
                    (void)strcpy (tpinitbuf->;cltname, "*" ;
                    (void)strcpy (tpinitbuf->;grpname, "" ;

                    if ((passwd = getpass("User Password:") == NULL) {
                        (void)userlog ("ERROR: Unable to get User Password";
                        exit(3) ;
                    }
                    (void)strcpy ((char *) &tpinitbuf->;data, passwd) ;

                    tpinitbuf->;datalen = strlen ((char *) &tpinitbuf->;data)+1L;
                    break ;
        }

        /* Join application */

        if (tpinit(tpinitbuf) == -1) {
                (void)fprintf(stderr, "Failed to join application, %s\n",
                        tpstrerror(tperrno));
                (void)userlog("Failed to join application, %s",
                        tpstrerror(tperrno));
                exit(1);
        }
       
        /*
         * string buffer will be used to convey balance request and return
         * results from conversational service.
         */

        if ((line = tpalloc("STRING","",LINE+1)) == (char *)NULL) {
                (void)fprintf(stderr,"tpalloc failed tperrno %d\n", tperrno);
                (void)userlog("tpalloc failed tperrno %d", tperrno);
                exit(1);
        }

        /* start global transaction with no timeout        */

        if (tpbegin(0,0) == -1) {
                (void)fprintf(stderr,"tpbegin failed tperrno %d\n",tperrno);
                (void)userlog("tpbegin failed tperrno %d",tperrno);
                (void)tpabort(0);
                (void)tpterm();
                exit(1);
        }

        /* open connection to audit conversational service.        */

        if ((cd = tpconnect("AUDITC",NULL,0,TPSENDONLY)) == -1) {
                (void)fprintf(stderr,"tpconnect failed tperrno %d\n", tperrno);
                (void)userlog("tpconnect failed tperrno %d", tperrno);
                (void)tpabort(0);
                (void)tpterm();
                exit(1);
        }

        /* repeatively query user for balance request type.        */

        (void)puts("to request a TELLER or ACCOUNT balance for a branch, type";
        (void)puts("the letter t or a, followed by the branch id, followed by <return>;\n";
        (void)puts("for ALL TELLER or ACCOUNT balances, type t or a <return>;\n");
        (void)puts("q <return>; quits the program\n");
        for (;;) {
                (void)gets(reply);
                (void) strcpy(line,reply);

                /* send balance request and relinquish line control.        */

                if (tpsend(cd,line,0,TPRECVONLY,&revent) == -1) {
                        (void)fprintf(stderr,"tpsend failed tperrno %d\n", tperrno);
                        (void)userlog("tpsend failed tperrno %d", tperrno);
                        (void)tpabort(0);
                        (void)tpterm();
                        exit(1);
                }

                /* wait for service to return balance request results.        */

                if (tprecv(cd,&line,&len,TPNOCHANGE,&revent) != -1) {
                        (void)fprintf(stderr,"tprecv failed tperrno %d revent %ld\n",
                                tperrno,revent);
                        (void)userlog("tprecv failed tperrno %d revent %ld",
                                tperrno,revent);
                        (void)tpabort(0);
                        (void)tpterm();
                        exit(1);
                }

                /* anything other than a send or disconnect event is an error.*/

                if ((tperrno != TPEEVENT) || ((revent != TPEV_SENDONLY) &&
                        (revent != TPEV_SVCSUCC))) {
                        (void)fprintf(stderr,"tprecv failed tperrno %d revent %ld\n",
                                tperrno,revent);
                        (void)userlog("tprecv failed tperrno %d revent %ld",
                                tperrno,revent);
                        (void)tpabort(0);
                        (void)tpterm();
                        exit(1);
                }
                if (strcmp(reply, "q") == 0 || revent == TPEV_SVCSUCC)
                        break;
                (void) printf("%s\n_________\nanother balance request ??\n",line);
        }


        if (tpcommit(0) == -1) {
                (void)fprintf(stderr,"tpcommit failed tperrno %d\n",
                        tperrno);
                (void)userlog("tpcommit failed tperrno %d",
                        tperrno);
                (void)tpterm();
                exit(1);
        }
       
        /* Leave application */

        if (tpterm() == -1) {
                (void)fprintf(stderr,"failed to leave application\n\n");
                (void)userlog("failed to leave application\n");
                exit(1);
        }
        return(0);
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP