tuxedo는 TOUPPER 서비스를 함수로 저장해놨습니다. 

 

.c 로 되어있는 파일을 실행모듈로 만들어야 서비스 호출이 가능해집니다.

 

ex )

simpserv.c

 

buildserver -o simpserv -f simpserv -s TOUPPER

 

 

그렇다면 TOLOWER는 안될까요?

 

이 부분에 대한 테스트를 진행해보죠. 

 

 

 

 

 

 

1. ubbconfig 파일에서 TOLOWER 서비스를 가질 AP 서버를 만듭니다.

 

 

*RESOURCES
IPCKEY          123457

DOMAINID        simpapp
MASTER          simple
MAXACCESSERS    500
MAXSERVERS      50
MAXSERVICES     100
MODEL           SHM
LDBAL           N

*MACHINES
DEFAULT:

                APPDIR="/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp"
                TUXCONFIG="/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp/tuxconfig"
                TUXDIR="/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0"
                MAXWSCLIENTS=400


node1   LMID=simple

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

GROUP1
        LMID=simple GRPNO=2  OPENINFO=NONE

GROUP2
        LMID=simple GRPNO=3  OPENINFO=NONE

*SERVERS
DEFAULT:
                CLOPT="-A"

WSL     SRVGRP=WSLGRP SRVID=200

        CLOPT="-A -- -n //211.110.82.xxx:5500 -p 5501 -P 5599  -w W
SH -t 15 -m 20 -M 30 -x 10"

simpserv        SRVGRP=GROUP1 SRVID=1

simpserv2       SRVGRP=GROUP2 SRVID=2

 

 

2. buildserver로 simpserv.c 파일을 컴파일 해줘야합니다.

 

(buildserver -o 생성할 실행모듈의 이름 -f .c파일 -s 서비스명)

 

simpserv.c 를 simpserv2 실행모듈로 컴파일 해줍니다.

 

buildserver -o -simpserv2 -f simpserv.c -s TOLOWER

 

 

 

하지만 에러가 나올 것입니다.

 

또한 simpserv.c 는 TOUPPER 서비스를 함수 형태로 가지고 있는 파일이기 때문에 

만들어진 실행모듈 simpserv2 로는 TOLOWER 서비스를 호출하지 못할 것입니다.

 

저 코드를 실행하였을 때 

나오는 에러는 다음과 같습니다.

 

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# buildserver -o simpserv2 -f simpserv.c -s TOLOWER
BS-185029c.c:
simpserv.c:
ld: 0711-224 WARNING: Duplicate symbol: tpsvrinit
ld: 0711-224 WARNING: Duplicate symbol: .tpsvrinit
ld: 0711-224 WARNING: Duplicate symbol: .userlog
ld: 0711-224 WARNING: Duplicate symbol: userlog
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
ld: 0711-317 ERROR: Undefined symbol: TOLOWER
CMDTUX_CAT:1832: ERROR: can't execute cc -q64 -D_LARGE_FILES -D__XCOFF32__ -D__XCOFF64__ -brtl -qstat-o simpserv2 BS-185029c.c simpserv.c  -L${TUXDIR}/lib  -brtl -qstaticinline  -ltux -lbuft   -lfml -l

 

 

 

하지만 소문자 tolower로 서비스를 생성하여 컴파일 해줬을 때는 

에러가 나오지 않았습니다.

 

 

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# buildserver -o simpserv2 -f simpserv.c -s tolower
BS-1940162.c:
simpserv.c:
ld: 0711-224 WARNING: Duplicate symbol: tpsvrinit
ld: 0711-224 WARNING: Duplicate symbol: .tpsvrinit
ld: 0711-224 WARNING: Duplicate symbol: .userlog
ld: 0711-224 WARNING: Duplicate symbol: userlog
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

 

 

왜 그랬던 걸까요?

 

결과적으로는 TOLOWER가 맞습니다.

 


 

tmadmin -r 로 접속하여 

 

 

프로세서들이 잘 진행되었는지 명령어들로 확인해봤습니다.

 

어? tolower 서비스가 올라와있습니다!

 

그런데 결과적으로는 TOLOWER가 맞다는 것 입니다.

 

그렇다면 tolower는 그냥 빈 껍데기겠죠?

 

저는 이부분에 대해서 차근차근 진행해보면서 답을 알게되었습니다.

 

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# tmadmin -r
tmadmin - Copyright (c) 1996-2016 Oracle.
All Rights Reserved.
Distributed under license by Oracle.
Tuxedo is a registered trademark.
TMADMIN_CAT:199: WARN: Cannot become administrator.Limited set of commands available.

> psr
Prog Name      Queue Name  2ndQueue Name  Grp Name      ID RqDone Load Done Current Service
---------      ----------  ----------     --------      -- ------ --------- ---------------
WSL            00001.00200                WSLGRP       200      0         0 (  IDLE )
BBL            123457                     simple         0      0         0 (  IDLE )
simpserv       00002.00001                GROUP1         1      0         0 (  IDLE )
simpserv2      00003.00002                GROUP2         2      0         0 (  IDLE )

> psc
Service Name Routine Name Prog Name  Grp Name  ID    Machine  # Done Status
------------ ------------ ---------  --------  --    -------  ------ ------
TOUPPER      TOUPPER      simpserv   GROUP1     1     simple       0 AVAIL
tolower      tolower      simpserv2  GROUP2     2     simple       0 AVAIL

> pclt
     LMID         User Name       Client Name    Time    Status  Bgn/Cmmt/Abrt
--------------- --------------- --------------- -------- ------- -------------
simple          jwchoi          WSH              0:00:15 IDLE    0/0/0
simple          jwchoi          WSH              0:00:15 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:14 IDLE    0/0/0
simple          jwchoi          WSH              0:00:13 IDLE    0/0/0
simple          jwchoi          WSH              0:00:13 IDLE    0/0/0
simple          jwchoi          WSH              0:00:13 IDLE    0/0/0
simple          jwchoi          tmadmin          0:00:04 IDLE    0/0/0

> psr
Prog Name      Queue Name  2ndQueue Name  Grp Name      ID RqDone Load Done Current Service
---------      ----------  ----------     --------      -- ------ --------- ---------------
WSL            00001.00200                WSLGRP       200      0         0 (  IDLE )
BBL            123457                     simple         0      1        50 (  IDLE )
simpserv       00002.00001                GROUP1         1      3       150 (  IDLE )
simpserv2      00003.00002                GROUP2         2      0         0 (  IDLE )

 

 

위에 말씀드렸다시피 또 한가지 문제점은 

 

simpserv.c 는 TOUPPER 서비스를 함수 형태로 가지고 있는 파일이기 때문에

만들어진 실행모듈 simpserv2 로는 TOLOWER 서비스를 호출하지 못할 것 ' 

 

이라는 것 입니다 !

 

 

 

그렇다면 어떻게 해야할까요?

 

 

제가 앞서 만든 실행모듈 simpserv2 는 simpserv.c 파일을 컴파일한 내용들이 들어있습니다.

따라서 TOUPPER 서비스를 가지고 있을 것 입니다.

 

아무리 서비스 호출을 해봤자 안될 것 입니다.

 

해답은 .c 파일을 따로 복사하여 서비스 함수를 바꿔준다음 다시 buildserver로 컴파일을 진행하는 것 입니다.

 

 

말한대로 진행해보겠습니다.

 

simpserv.c 파일을 cp로 복사합니다.

cp simpserv.c simpserv2.c

그리고 vi simpserv2.c 로 들어가 

 

TOUPPER 부분들이 있는 로직들을 모두 tolower 서비스로 바꿔주었습니다. 코드 맨 아래로 내려보시면 됩니다.

 

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# vi simpserv2.c
"simpserv2.c" 85 lines, 2155 characters 
/*
        Copyright (c) 2011 Oracle, Inc.
        All rights reserved

        THIS IS UNPUBLISHED PROPRIETARY
        SOURCE CODE OF ORACLE, Inc.
        The copyright notice above does not
        evidence any actual or intended
        publication of such source code.
*/


/*      (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/simpserv.c   $Revision: 1.7 $" */

#include <stdio.h>
#include <ctype.h>
#include <atmi.h>       /* TUXEDO Header File */
#include <userlog.h>    /* TUXEDO Header File */

/* tpsvrinit is executed when a server is booted, before it begins
   processing requests.  It is not necessary to have this function.
   Also available is tpsvrdone (not used in this example), which is
   called at server shutdown time.
*/

#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;

        /* simpapp is non-transactional, so there is no need for tpsvrinit()
           to call tx_open() or tpopen().  However, if this code is modified
           to run in a Tuxedo group associated with a Resource Manager then
           either a call to tx_open() or a call to tpopen() must be inserted
           here.
        */
"simpserv2.c" 85 lines, 2155 characters
           either a call to tx_open() or a call to tpopen() must be inserted
           here.
        */

        /* userlog writes to the central TUXEDO message log */
        userlog("Welcome to the simple server");
        return(0);
}

/* This function performs the actual service requested by the client.
   Its argument is a structure containing among other things a pointer
   to the data buffer, and the length of the data buffer.
*/

#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) || defined(__cplusplus)
tolower(TPSVCINFO *rqst)
#else
tolower(rqst)
TPSVCINFO *rqst;
#endif
{

        int i;

        for(i = 0; i < rqst->len-1; i++)
                rqst->data[i] = tolower(rqst->data[i]);

        /* Return the transformed buffer to the requestor. */
        tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}

 

 

 

이제 buildserver로 컴파일을 해줄 단계 입니다.

 

buildserver -o 생성할 실행모듈의 이름 -f .c파일 -s 서비스명 

buildserver -o simpserv2 -f simpserv2.c -s tolower

 

그런데 이런 에러가 나옵니다.

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# serv2 -f simpserv2.c -s tolower
BS-1f0244.c:
simpserv2.c:
"simpserv2.c", line 73.1: 1506-343 (S) Redeclaration of tolower differs from previous declaration on  "/usr/include/ctype.h".
"simpserv2.c", line 73.1: 1506-050 (I) Return type "void" in redeclaration is not compatible with theeturn type "int".
"simpserv2.c", line 73.1: 1506-381 (I) The type "int" of parameter 1 in the prototype declaration is ble with the corresponding parameter type "struct tpsvcinfo*" in the nonprototype declaration.
CMDTUX_CAT:1832: ERROR: can't execute cc -q64 -D_LARGE_FILES -D__XCOFF32__ -D__XCOFF64__ -brtl -qstat-I$TUXDIR/include -o simpserv2 BS-1f0244.c simpserv2.c  -L${TUXDIR}/lib  -brtl -qstaticinline  -ltux fml -lfml32 -lengine -lpthread

 

왜 그런 것인지 모르겠으니 vi 로 진입하여 73번째 라인을 살펴보았으나 아무 문제 없었습니다.

 

제 생각으로는 .c 파일 내에 들어있는 함수 형태로 만들어진 서비스는 "대문자" 이어야 한다는 생각이 들었습니다.

제가 앞에서 만든 서비스명은 아마 껍떼기 이었을 것 입니다.

 

그래서 컴파일 하기 전, 다시 대문자로 바꿔주었습니다. (if문 속의 tolower는 고쳐주실 필요 없습니다. 소문자 tolower 자체가 함수이기 때문 입니다.

 

다음과 같이 설정 후 wq로 저장하였습니다.

   +60
   +61  /* This function performs the actual service requested by the client.
   +62     Its argument is a structure containing among other things a pointer
   +63     to the data buffer, and the length of the data buffer.
   +64  */
   +65
   +66  #ifdef __cplusplus
   +67  extern "C"
   +68  #endif
   +69  void
   +70  #if defined(__STDC__) || defined(__cplusplus)
   +71  TOLOWER(TPSVCINFO *rqst)
   +72  #else
   +73  TOLOWER(rqst)
   +74  TPSVCINFO *rqst;
   +75  #endif
   +76  {
   +77  
   +78          int i;
   +79  
   +80          for(i = 0; i < rqst->len-1; i++)
   +81                  rqst->data[i] = tolower(rqst->data[i]);
   +82  
   +83          /* Return the transformed buffer to the requestor. */
   +84          tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
   +85  }

 

그럼 다시 buildserver로 컴파일을 진행해보겠습니다.

서비스명을 대문자로 해줍니다.

 

buildserver -o simpserv2 -f simpserv2.c -s TOLOWER

 

에러가 나지 않고 정상적으로 실행모듈이 생성되었습니다..

 

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# f simpserv2.c -s TOLOWER <
BS-2ef0102.c:
simpserv2.c:
ld: 0711-224 WARNING: Duplicate symbol: .tpsvrinit
ld: 0711-224 WARNING: Duplicate symbol: .userlog
ld: 0711-224 WARNING: Duplicate symbol: userlog
ld: 0711-224 WARNING: Duplicate symbol: tpsvrinit
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

 

실행모듈을 실행시켜줍니다.


정상적으로 simpserv2 라는  AP server가 실행되었습니다.

[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# tmboot -s simpserv2
INFO: Oracle Tuxedo, Version 12.2.2.0.0, 64-bit, Patch Level (none)

Booting server processes ...

exec simpserv2 -A :
        process id=43516274 ... Started.
1 process started.
[node1@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# tmadmin -r 
tmadmin - Copyright (c) 1996-2016 Oracle.
All Rights Reserved.
Distributed under license by Oracle.
Tuxedo is a registered trademark.
TMADMIN_CAT:199: WARN: Cannot become administrator.Limited set of commands available.

> psr
Prog Name      Queue Name  2ndQueue Name  Grp Name      ID RqDone Load Done Current Service
---------      ----------  ----------     --------      -- ------ --------- ---------------
WSL            00001.00200                WSLGRP       200      0         0 (  IDLE )
BBL            123457                     simple         0      0         0 (  IDLE )
simpserv       00002.00001                GROUP1         1      0         0 (  IDLE )
simpserv2      00003.00002                GROUP2         2      0         0 (  IDLE )

> psc
Service Name Routine Name Prog Name  Grp Name  ID    Machine  # Done Status
------------ ------------ ---------  --------  --    -------  ------ ------
TOUPPER      TOUPPER      simpserv   GROUP1     1     simple       0 AVAIL
TOLOWER      TOLOWER      simpserv2  GROUP2     2     simple       0 AVAIL

 

그렇다면 이제 client가 TOLOWER 서비스를 호출을 할 수 있을 것 입니다.

 

 

 

Client는 무엇을 설정해줘야만 AP서버의 TOLOWER 서비스를 호출할 수 있을까요?

 

정답은

ubbconfig 파일에서 WSL 프로세스의 포트를 지정해준 곳으로, 즉  client는 그 포트를 통해서 tuxedo에 접속하게 됨으로써 서비스를 호출할 수 있을 것 입니다.

 

그러기 위해서 클라이언트는 WSL로 접속하기 위해 WSNADDR 이라는 환경변수를 설정해주게 됩니다.

 

export WSNADDR=//IP:Port 

 

ex) 

export WSNADDR=//211.123.55.111:5555

 

이렇게 설정을 하게 되면 client는 WSL에 접속을 하게 됩니다.

 

이와 동시에 simpcl.c 이라는 클라이언트 설정 파일을 컴파일 해주어야 합니다.

 

이 부분은 buildserver를 했던 과정과 똑같습니다.

 

위에도 말씀드렸다시피 tuxedo를 설치하게 되면 기본적으로 내장되어 함수처리된 서비스인 TOUPPER가 있습니다. 

 

때문에 simpcl.c 파일도 TOUPPER 서비스에 관한 내용이 있기 때문에 이 파일을 그대로 컴파일하여서 TOLOWER 서비스를 불러오고자 한다면 에러가 나오게 됩니다.

 

그러니... 

 

복사를 해주고,

cp simpcl.c simpcl2.c

 

simpcl2.c 를 아래와 같이 vi 편집을 해줘야 합니다.

 

 

 

[node2@jwchoi:/ofm/jwchoi/sw/tp/tuxedo12.2.2.0.0/samples/atmi/simpapp]# vi simpcl2.c   
"simpcl2.c" 81 lines, 1826 characters 
/*      (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/simpcl.c     $Revision: 1.5 $" */

#include <stdio.h>
#include "atmi.h"               /* 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 */
"simpcl2.c" 81 lines, 1826 characters

        /* 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 TOLOWER, waiting for a reply */
        ret = tpcall("TOLOWER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);

        if(ret == -1) {
                (void) fprintf(stderr, "Can't send request to service TOLOWER\n");
                (void) fprintf(stderr, "Tperrno = %d\n", tperrno);
                tpfree(sendbuf);
                tpfree(rcvbuf);
                tpterm();
                exit(1);
        }

        (void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);

        /* Free Buffers & Detach from System/T */
        tpfree(sendbuf);
        tpfree(rcvbuf);
        tpterm();
        return(0);
}
~
~
~
~
~
~
~
        return(0);
}
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
        }

        /* 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 TOLOWER, waiting for a reply */
        ret = tpcall("TOLOWER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);

        if(ret == -1) {
                (void) fprintf(stderr, "Can't send request to service TOLOWER\n");
                (void) fprintf(stderr, "Tperrno = %d\n", tperrno);
                tpfree(sendbuf);
                tpfree(rcvbuf);
                tpterm();
                exit(1);
        }

        (void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);

        /* Free Buffers & Detach from System/T */
        tpfree(sendbuf);
        tpfree(rcvbuf);
        tpterm();
/*      (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/simpcl.c     $Revision: 1.5 $" */

#include <stdio.h>
#include "atmi.h"               /* 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 */

        /* 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 TOLOWER, waiting for a reply */
        ret = tpcall("TOLOWER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);

        if(ret == -1) {
                (void) fprintf(stderr, "Can't send request to service TOLOWER\n");
                (void) fprintf(stderr, "Tperrno = %d\n", tperrno);
                tpfree(sendbuf);
                tpfree(rcvbuf);
                tpterm();
                exit(1);
        }

        (void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);

        /* Free Buffers & Detach from System/T */
        tpfree(sendbuf);
        tpfree(rcvbuf);
        tpterm();
        return(0);
}

 

코드를 잘 읽어가면서 내려가는 습관도 들이면 아주 좋을 것 같습니다. (저에게 하는 말)

 

TOUPPER 부분을 TOLOWER로 바꿔주면 되는 간단한 작업을 마치게 되면 

 

:wq 로 편집기를 나오면 됩니다..

 

 

 

이제 클라이언트파일을 컴파일 해야합니다.

buildclient -w -o simpcl2 -f simpcl2.c

 

 

이 과정을 모두 마치게 되면...

 

서비스를 호출해봅니다.

 

 

./simpcl2 "대문자" 를 실행하게 되면 문자열이 소문자로 리턴되는 것을 확인할 수 있습니다.

 

 

 

 

이상입니다.

 

 

 

궁금하신 점이 있다면 댓글로 남겨주세요!

 

함께 공부하고 싶습니다.

 

 

 

감사합니다.

 

 

 

 

 

 

 

 

 

+ Recent posts