I'm writing a simple server-client using MIDL
and RPC
to allow file transferring.
It works when endpoint is hard coded as follow:
server side
status = RpcServerUseProtseqEp(
reinterpret_cast<unsigned char*>("ncacn_ip_tcp"),
RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
reinterpret_cast<unsigned char*>("8888"),
NULL);
Client Side
status = RpcStringBindingCompose(NULL,
"ncacn_ip_tcp",
(RPC_CSTR)"127.0.0.1",
"8888",
NULL,
NULL);
I'm wondering if multiple clients are able to connect to one server when endpoint is hard coded? As we know that in socket programming using TCP protocol, two application cannot connect to a single port at one time. However, the MSDN
reference says that RPC
server process uses a first-in, first-out call queue to handle requests.
If it is unable to receive multiple requests from clients, is there a way to set an endpoint pool? Thank you.
You're confusing the terminology here.
The server is listening on a TCP port. That means it binds to the port and starts the accept loop on it. Every time that a new client connects to this port, the accept function establishes a TCP connection with that client, and goes back to listening on the port.
The server application is either a multi-threaded or an asynchronous application that handles multiple actions simultaneously: listening for new clients, communicating with each connected client and performing the actual work.
A typical RPC server would look something like
The
RpcServerListen
call would block forever, startcMinCalls
worker threads and perform theaccept
loop, accepting the connections and handling the requests in up tocMinCalls
parallel threads.