大网数据广告活动
网络与域名解析

Client-side Binding

· 52CE 我爱测

Binding handles are composed of a protocol sequence, the name or address of a server program host computer, and a server program endpoint. Therefore, your client program must obtain or provide this information to create a binding.

Binding handles are composed of a protocol sequence, the name or address of a server program host computer, and a server program endpoint. Therefore, your client program must obtain or provide this information to create a binding.

If your client program uses automatic binding handles, you do not need to write special source code to create or manage the binding. The client stub calls RPC functions required to establish and maintain the binding. All you have to do is specify that your client uses automatic binding handles in the application configuration file (ACF), and design the interface accordingly. For details, see Automatic Binding Handles.

Suppose, for example, that you were developing a client program that called remote time-stamping functions. Here, the stubs do all the work and the client only needs to include the generated header file Auto.h to obtain the function prototypes for the remote procedures. The client application calls to the remote procedures appear just as if they were calls to local procedures, as shown in the following example:

/* auto handle client application (fragment) */
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include "auto.h"    // header file generated by the MIDL compiler
 
 
void main(int argc, char **argv)
{
    time_t t1;
    time_t t2;
    char * pszTime;
    ...
 
    GetTime(&t1);  // GetTime is a remote procedure
    GetTime(&t2);
 
    pszTime = ctime(&t1);
    printf("time 1= %s\n", pszTime);
 
    pszTime = ctime(&t2);
    printf("time 2= %s\n", pszTime);
 
    Shutdown();    // Shutdown is a remote procedure
    exit(0);
}

As you can see in the preceding example, the client application does not have to make any explicit calls to the RPC run-time library functions. The client stub manages them.

If your application uses implicit or explicit binding handles, the client must obtain the binding information and call the RPC functions to create the handles. Where the client obtains the binding information from depends on the requirements of your application. The setup program that installs your client application can store binding information in environment variables that it creates. It can also save binding information in an application-specific configuration file. Since binding information in environment variables or configuration files is usually stored as strings, your client application will need to convert the string to a binding. In Windows XP/2000 environments, binding information can be retrieved from Active Directory. For more information, see Using String Bindings.

Most networks have a name service. Server programs can advertise themselves in the name service database. When a client begins execution, it can obtain its binding information from the name service database. For details, see Importing from Name Service Databases.

The steps required for binding with implicit and explicit handles are discussed in the following topics:

For a brief overview of these topics, see Connecting the Client and the Server.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。