Send Request Extension API

This API issues the Send Request or the Resend Request.

Syntax

INT __stdcall   utlrecvex( LPCSTR lpszFileID , LPCSTR lpszHostName , 
                BOOL bResend , BOOL bNp , BOOL bSync , INT nWait , 
                HULMSGS* lpMsg , INT nTransMode , SHORT nPriority );

Explanation of the parameters

LPCSTR lpszFileID (IN)

Specify the file ID of the file to receive

Specify the file ID as a character string within 50 bytes. To omit this parameter, specify 'NULL.'

LPCSTR lpszHostName (IN)

Specify the name of the remote host to which you issue a request for the Send processing

Specify the host name as a character string within 68 bytes. To omit this parameter, specify 'NULL.'

For the Resend Request (bResend=TRUE), this parameter is mandatory.

BOOL bResend (IN)

Specify the Resend Request flag

TRUE:

Specify the Resend Request

FALSE:

Specify the Send Request

BOOL bNp (IN)

Specify the Checkpoint flag

For the Send Request (bResend=FALSE), be sure to specify 'FALSE.'

TRUE:

Carry out transfer of the Resend Request from the beginning of the file

FALSE:

Carry out the Checkpoint Resend Request

BOOL bSync (IN)

Specify the synchronous transfer flag

For the Resend Request (bResend = TRUE), you cannot specify Synchronous Transfer.

TRUE:

Carry out Synchronous Transfer

FALSE:

Do not carry out Synchronous Transfer

INT nWait (IN)

Specify the wait time of Synchronous Transfer (in seconds)

When you specify the Synchronous Transfer, set the wait time for synchronizing the transfer with the result of processing, in the range from '10' to '259200.' When it reaches the time that you specified, HULFT resumes processing even if it is in the middle of receiving. In this case, note that HULFT does not return the transfer results.

The parameter is enabled only when the Synchronous Transfer (bSync=TRUE) is specified. When you do not intend to carry out the Synchronous Transfer (bSync=FALSE), specify '0.'

When you specify '0' for this parameter, HULFT applies the set value of Socket Read Timeout (socktime) in the System Environment Settings file (hulenv.cnf).

HULMSGS* lpMsg (IN)

Specify the message structure

For the Resend Request (bResend=TRUE), be sure to specify 'NULL.'

Specify 'NULL' also to omit this parameter.

The details of the structure are as mentioned below.

When you do not use long messages, you do not need to include 'exmsginfo' in the message structure.

typedef struct _tagHULMSGS { 
    DWORD msgcnt;        // Number of messages that are stored 
    CHAR** msginfo;      // Message table ($MSG0 to $MSG5) 
    CHAR** exmsginfo;    // Long Message table ($MSGL0 to $MSGL1) 
} HULMSGS;

DWORD msgcnt

Number of messages that are stored

If you do not use long messages, specify '6.'

If you use long messages, specify '8.'

CHAR** msginfo

This parameter specifies messages.

For each message, you can specify up to 50 bytes at maximum. Be sure to allocate a fixed-size array that is calculated by the formula 'Number of messages (6) x (maximum length 50 bytes + 1).' Specify each message every 51 bytes from the top. When the function ends, release the memory.

CHAR** exmsginfo

This parameter specifies long messages.

Specify this parameter when you use long messages.

Each long message can be specified up to a maximum of 200 bytes. Be sure to allocate a fixed-size array that is calculated by the formula 'Number of long messages (2) x (maximum length 200 bytes +1).' Specify each long message every 201 bytes from the top. When the function ends, release the memory.

INT nTransMode (IN)

Specify the transfer mode

Specify '0' as a fixed value.

SHORT nPriority (IN)

Specify the priority for a transfer that uses a telephone connection

Specify '0' as a fixed value.

Note

When you specify 'NULL' for both lpszFileID and lpszHostName, HULFT carries out Resend Request to all hosts.

Returned Value

This function returns '0' if the processing completes successfully. The status when an error occurs is the same as the error code of 'utlrecv.exe.'

For details, refer to Error Codes and Messages.

<Usage example>

Specifying settings when using Visual C++ (when long messages are not used)

#include <windows.h>
#include <stdio.h>

#pragma pack(push,8) 
typedef struct { 
    DWORD msgcnt; 
    CHAR** msginfo; 
} HULMSGS; 
#pragma pack(pop) 

typedef INT (__stdcall *LPUTLRECVEX)( 
        LPCSTR lpszFileID, LPCSTR lpszHostName, BOOL bResend, 
        BOOL bNp, BOOL bSync, INT nWait, 
        HULMSGS* lpMsg, INT nTransMode, SHORT nPriority); 

int main() 
{ 
    CHAR szFileID[50+1]; 
    CHAR szHostName[68+1]; 
    BOOL bResend; 
    BOOL bNp; 
    BOOL bSync; 
    INT nWait; 
    HULMSGS sMsgInfo; 
    CHAR* msgbodyptr[6]; 
    CHAR msgbody[(50+1)*6]; 
    INT nTransMode; 
    SHORT nPriority; 
    INT i; 
    HMODULE hHulDll; 
    HMODULE hApiDll; 
    LPUTLRECVEX lpUtlrecvex; 
    INT nStatus; 

    strcpy_s(szFileID, sizeof(szFileID), "TEST0001"); 
    strcpy_s(szHostName, sizeof(szHostName), "host0001"); 
    bResend = FALSE; 
    bNp = FALSE; 
    bSync = TRUE; 
    nWait = 300; 
    nTransMode = 0; 
    nPriority = 0; 

    sMsgInfo.msgcnt = 6; 
    sMsgInfo.msginfo = msgbodyptr; 
    for (i = 0; i < 6; i++) 
    { 
        sMsgInfo.msginfo[i] = &msgbody[51*i]; 
    } 
    strcpy_s(sMsgInfo.msginfo[0], 51, "host0001"); 
    strcpy_s(sMsgInfo.msginfo[1], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[2], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[3], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[4], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[5], 51, ""); 

    hHulDll = LoadLibrary("C:\\HULFT Family\\hulft8\\bin\\hulftrt.dll"); 
    if (hHulDll == NULL) 
    { 
        printf("Unable to load hulftrt.dll." 
            "(Error code=%lu)\n", GetLastError()); 
        return 1; 
    } 
    hApiDll = LoadLibrary("C:\\HULFT Family\\hulft8\\bin\\hulapi.dll"); 
    if (hApiDll == NULL) 
    { 
        printf("Unable to load hulapi.dll." 
            "(Error code=%lu)\n", GetLastError()); 
        FreeLibrary(hHulDll); 
        return 2; 
    } 
    lpUtlrecvex = (LPUTLRECVEX)GetProcAddress(hApiDll, "utlrecvex"); 
    if (lpUtlrecvex == NULL) 
    { 
        printf("Unable to retrieves the address of HULFT API." 
            "(Error code=%lu)\n", GetLastError()); 
        FreeLibrary(hApiDll); 
        FreeLibrary(hHulDll); 
        return 3; 
    } 
    nStatus = lpUtlrecvex(szFileID, szHostName, bResend, bNp, bSync, 
            nWait, &sMsgInfo, nTransMode, nPriority); 
    if (nStatus == 0) 
    { 
        printf("Terminated normally.\n"); 
    } 
    else 
    { 
        printf("Error occurred when calling HULFT API." 
            "(Returned value=%d)\n", nStatus); 
    } 
    FreeLibrary(hApiDll); 
    FreeLibrary(hHulDll); 
    return 0; 
}

Specifying settings when using Visual C++ (when long messages are used)

#include <windows.h>
#include <stdio.h>

#pragma pack(push,8) 
typedef struct { 
    DWORD msgcnt; 
    CHAR** msginfo; 
    CHAR** exmsginfo; 
} HULMSGS; 
#pragma pack(pop) 

typedef INT (__stdcall *LPUTLRECVEX)( 
        LPCSTR lpszFileID, LPCSTR lpszHostName, BOOL bResend, 
        BOOL bNp, BOOL bSync, INT nWait, 
        HULMSGS* lpMsg, INT nTransMode, SHORT nPriority); 

int main() 
{ 
    CHAR szFileID[50+1]; 
    CHAR szHostName[68+1]; 
    BOOL bResend; 
    BOOL bNp; 
    BOOL bSync; 
    INT nWait; 
    HULMSGS sMsgInfo; 
    CHAR* msgbodyptr[6]; 
    CHAR msgbody[(50+1)*6]; 
    CHAR* exmsgbodyptr[2]; 
    CHAR exmsgbody[(200+1)*2]; 
    INT nTransMode; 
    SHORT nPriority; 
    INT i; 
    HMODULE hHulDll; 
    HMODULE hApiDll; 
    LPUTLRECVEX lpUtlrecvex; 
    INT nStatus; 

    strcpy_s(szFileID, sizeof(szFileID), "TEST0001"); 
    strcpy_s(szHostName, sizeof(szHostName), "host0001"); 
    bResend = FALSE; 
    bNp = FALSE; 
    bSync = TRUE; 
    nWait = 300; 
    nTransMode = 0; 
    nPriority = 0; 

    sMsgInfo.msgcnt = 8; 
    sMsgInfo.msginfo = msgbodyptr; 
    for (i = 0; i < 6; i++) 
    { 
        sMsgInfo.msginfo[i] = &msgbody[51*i]; 
    } 
    strcpy_s(sMsgInfo.msginfo[0], 51, "host0001"); 
    strcpy_s(sMsgInfo.msginfo[1], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[2], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[3], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[4], 51, ""); 
    strcpy_s(sMsgInfo.msginfo[5], 51, ""); 
    sMsgInfo.exmsginfo = exmsgbodyptr; 
    for (i = 0; i < 2; i++) 
    { 
        sMsgInfo.exmsginfo[i] = &exmsgbody[201*i]; 
    } 
    strcpy_s(sMsgInfo.exmsginfo[0], 201, "host0002"); 
    strcpy_s(sMsgInfo.exmsginfo[1], 201, ""); 

    hHulDll = LoadLibrary("C:\\HULFT Family\\hulft8\\bin\\hulftrt.dll"); 
    if (hHulDll == NULL) 
    { 
        printf("Unable to load hulftrt.dll." 
            "(Error code=%lu)\n", GetLastError()); 
        return 1; 
    } 
    hApiDll = LoadLibrary("C:\\HULFT Family\\hulft8\\bin\\hulapi.dll"); 
    if (hApiDll == NULL) 
    { 
        printf("Unable to load hulapi.dll." 
            "(Error code=%lu)\n", GetLastError()); 
        FreeLibrary(hHulDll); 
        return 2; 
    } 
    lpUtlrecvex = (LPUTLRECVEX)GetProcAddress(hApiDll, "utlrecvex"); 
    if (lpUtlrecvex == NULL) 
    { 
        printf("Unable to retrieves the address of HULFT API." 
            "(Error code=%lu)\n", GetLastError()); 
        FreeLibrary(hApiDll); 
        FreeLibrary(hHulDll); 
        return 3; 
    } 
    nStatus = lpUtlrecvex(szFileID, szHostName, bResend, bNp, bSync, 
            nWait, &sMsgInfo, nTransMode, nPriority); 
    if (nStatus == 0) 
    { 
        printf("Terminated normally.\n"); 
    } 
    else 
    { 
        printf("Error occurred when calling HULFT API." 
            "(Returned value=%d)\n", nStatus); 
    } 
    FreeLibrary(hApiDll); 
    FreeLibrary(hHulDll); 
    return 0; 
}