Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;:当端点被硬编码时,多个客户端能否侦听一个服务器?_C++_Sockets_Tcp_Rpc_Midl - Fatal编程技术网

C++ C++;:当端点被硬编码时,多个客户端能否侦听一个服务器?

C++ C++;:当端点被硬编码时,多个客户端能否侦听一个服务器?,c++,sockets,tcp,rpc,midl,C++,Sockets,Tcp,Rpc,Midl,我正在编写一个简单的服务器客户端,使用MIDL和RPC来允许文件传输。 当端点硬编码如下时,它工作: 服务器端 status = RpcServerUseProtseqEp( reinterpret_cast<unsigned char*>("ncacn_ip_tcp"), RPC_C_PROTSEQ_MAX_REQS_DEFAULT, reinterpret_cast<unsigned char*>("

我正在编写一个简单的服务器客户端,使用
MIDL
RPC
来允许文件传输。 当端点硬编码如下时,它工作:

服务器端

status = RpcServerUseProtseqEp(  
    reinterpret_cast<unsigned char*>("ncacn_ip_tcp"), 
    RPC_C_PROTSEQ_MAX_REQS_DEFAULT,                   
    reinterpret_cast<unsigned char*>("8888"),         
    NULL);                                            
我想知道当端点被硬编码时,多个客户端是否能够连接到一个服务器?我们知道,在使用TCP协议的套接字编程中,两个应用程序不能同时连接到单个端口。然而,
MSDN
引用指出,
RPC
服务器进程使用先进先出的调用队列来处理请求


如果无法接收来自客户端的多个请求,是否有方法设置端点池?谢谢。

你把这里的术语弄糊涂了

服务器正在TCP端口上侦听。这意味着它绑定到端口并在其上启动accept循环。每次新客户端连接到此端口时,accept函数都会与该客户端建立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
调用将永远阻塞,启动
cmincall
工作线程并执行
accept
循环,在最多
cmincall
并行线程中接受连接并处理请求。

您混淆了这里的术语

服务器正在TCP端口上侦听。这意味着它绑定到端口并在其上启动accept循环。每次新客户端连接到此端口时,accept函数都会与该客户端建立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
调用将永远阻塞,启动
cmincall
工作线程并执行
accept
循环,在多达
cmincall
并行线程中接受连接并处理请求。

服务器通常侦听客户端的请求。是否要检查此短语?通常服务器会侦听客户端的请求。你想检查一下这个短语吗?