Linkexpress 利用者プログラム開発ガイド
目次 索引 前ページ次ページ

付録A サンプル> A.1 転送APIのサンプル

A.1.9 応答側メッセージ受信の例

このサンプルプログラムは、以下のファイルに格納されています。

PCサーバ : インストールディレクトリ\sample\api\respapl3.c

UNIXサーバ : インストールディレクトリ/SAMPLE/api/respapl3.c

機能

このサンプルプログラムは、相手システムからのメッセージの受信を行うものです。プログラムの説明を以下に示します。

GETINFでメッセージを受け取り、TRANCOMPでその旨をLinkexpressに通知しています。

ソースコード

respapl3.cの内容を以下に示します。

/*
 *
 * All Rights Reserved Copyright (c) FUJITSU LIMITED 1997-2005
 *
 */

/*
 *      API sample program (resp no.3)
 */

/*
 *      include file
 */
#include        <sys/types.h>
#include        <string.h>
#include        <stdio.h>
#include        <fcntl.h>
#include        <lxapi.h> 

int
main()
{
unsigned long  req_ident;
FILE           *ofp;

    /*
     * getinf
     */
    {
    dts_getinf_dcb_t       input_dcb;
    dts_get_information_t  output_dcb;

        /*
         *    clear parameters
         */
        memset( &input_dcb, 0, sizeof(dts_getinf_dcb_t) );
        memset( &output_dcb, 0, sizeof(dts_get_information_t) );

        input_dcb.appl_name = "@_USRAPL";
        input_dcb.req_kind = DTS_API_RESP;
        input_dcb.info_kind = DTS_API_START_INFO;
        input_dcb.timer = 0;
        input_dcb.path_name = 0;

        getinf( &input_dcb, &output_dcb );

        ofp = fopen("C:\\test\\api\\resp1.txt", "a");
        (void)fprintf(ofp, "message_len = %d\n", 
                output_dcb.getinf_data.message.message_len);
        (void)fprintf(ofp, "message_text = %s\n",
                 output_dcb.getinf_data.message.message_text);
        (void)fprintf(ofp, "\n");
        (void)fflush(ofp);
        (void)fclose(ofp);

        req_ident = output_dcb.getinf_data.tstart.req_ident;
    }


    /*
     *    trancomp
     */
    {
    dts_trancomp_dcb_t  input_dcb;
    dts_diagnostic_t    output_dcb;

        /*
         *    clear parameters
         */
        memset( &input_dcb, 0, sizeof(dts_trancomp_dcb_t) );
        memset( &output_dcb, 0, sizeof(dts_diagnostic_t) );

        input_dcb.req_ident = req_ident;
        input_dcb.appl_name = "@_USRAPL";
        input_dcb.req_kind = DTS_API_RESP;
        input_dcb.appl_cont = DTS_API_APLCUT;

        trancomp( &input_dcb, &output_dcb );

    }

    fclose(ofp);
    return( 1 );

}

参照

lxapi.hdts_getinf_dcb_tdts_get_information_tdts_trancomp_dcb_tdts_diagnostic_t

用語解説

DTS_API_RESP
転送監視機能を使用するため、DTS_API_RESP(転送監視機能)を指定します。
DTS_API_START_INFO
開始情報を受信するため、DTS_API_START_INFO(開始情報)を指定します。
DTS_API_APLCUT
次にサービスがないため、DTS_API_APLCUT(切断)を指定します。

目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 1997-2007