C++ 中的远程过程调用 (RPC):当端点被硬编码时,多个客户端能否监听一台服务器?
Remote Procedure Call (RPC) in C++: Can multiple Clients listen to one server when endpoint is hard coded?
我正在使用 MIDL
和 RPC
编写一个简单的服务器客户端以允许文件传输。
它在端点硬编码如下时有效:
服务器端
status = RpcServerUseProtseqEp(
reinterpret_cast<unsigned char*>("ncacn_ip_tcp"),
RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
reinterpret_cast<unsigned char*>("8888"),
NULL);
客户端
status = RpcStringBindingCompose(NULL,
"ncacn_ip_tcp",
(RPC_CSTR)"127.0.0.1",
"8888",
NULL,
NULL);
我想知道当端点被硬编码时,多个客户端是否能够连接到一台服务器?正如我们所知,在使用 TCP 协议的套接字编程中,两个应用程序不能同时连接到一个端口。但是,MSDN
参考资料说 RPC
服务器进程使用先进先出调用队列来处理请求。
如果无法接收来自客户端的多个请求,是否可以设置端点池?谢谢。
你混淆了这里的术语。
服务器 正在侦听 TCP 端口。这意味着它绑定到端口并在其上启动接受循环。每次新客户端 连接 到此端口时,接受函数都会与该客户端建立 TCP 连接 ,然后返回监听端口.
服务器应用程序是多线程应用程序或异步应用程序,可同时处理多个操作:侦听新客户端、与每个连接的客户端通信并执行实际工作。
典型的 RPC 服务器看起来像
status = RpcServerUseProtseqEp(pszProtocolSequence,
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
pszEndpoint,
pszSecurity);
if (status) exit(status);
status = RpcServerRegisterIf(my_rpc_interface_spec,
NULL,
NULL);
if (status) exit(status);
status = RpcServerListen(cMinCalls,
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
0);
if (status) exit(status);
RpcServerListen
调用将永远阻塞,启动 cMinCalls
工作线程并执行 accept
循环,接受连接并处理最多 cMinCalls
并行的请求线程。
我正在使用 MIDL
和 RPC
编写一个简单的服务器客户端以允许文件传输。
它在端点硬编码如下时有效:
服务器端
status = RpcServerUseProtseqEp(
reinterpret_cast<unsigned char*>("ncacn_ip_tcp"),
RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
reinterpret_cast<unsigned char*>("8888"),
NULL);
客户端
status = RpcStringBindingCompose(NULL,
"ncacn_ip_tcp",
(RPC_CSTR)"127.0.0.1",
"8888",
NULL,
NULL);
我想知道当端点被硬编码时,多个客户端是否能够连接到一台服务器?正如我们所知,在使用 TCP 协议的套接字编程中,两个应用程序不能同时连接到一个端口。但是,MSDN
参考资料说 RPC
服务器进程使用先进先出调用队列来处理请求。
如果无法接收来自客户端的多个请求,是否可以设置端点池?谢谢。
你混淆了这里的术语。
服务器 正在侦听 TCP 端口。这意味着它绑定到端口并在其上启动接受循环。每次新客户端 连接 到此端口时,接受函数都会与该客户端建立 TCP 连接 ,然后返回监听端口.
服务器应用程序是多线程应用程序或异步应用程序,可同时处理多个操作:侦听新客户端、与每个连接的客户端通信并执行实际工作。
典型的 RPC 服务器看起来像
status = RpcServerUseProtseqEp(pszProtocolSequence,
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
pszEndpoint,
pszSecurity);
if (status) exit(status);
status = RpcServerRegisterIf(my_rpc_interface_spec,
NULL,
NULL);
if (status) exit(status);
status = RpcServerListen(cMinCalls,
RPC_C_LISTEN_MAX_CALLS_DEFAULT,
0);
if (status) exit(status);
RpcServerListen
调用将永远阻塞,启动 cMinCalls
工作线程并执行 accept
循环,接受连接并处理最多 cMinCalls
并行的请求线程。