[ Home | Syllabus |Course Notes]
Sources of significant overhead:
Based on Unix DCE( Distributed Computing Environment)
Annotate function prototype with type + use information
Basic Types supported:
Limited support for Pointers:
endpoint(protocol-sequence:[endpoint-port] [ ,
...] )
protocol-sequence
Specifies a character string that represents a valid combination
of an RPC protocol (such as ncacn), a transport
protocol (such as tcp), and a network protocol (such
as ip). Microsoft RPC supports the following protocol
sequences:
| Protocol sequence | Description | Supporting Platforms |
| ncacn_nb_tcp | Connection-oriented NetBIOS over TCP | Client and server: Windows NTClient only: MS-DOS, Windows 3.x |
| ncacn_nb_ipx | Connection-oriented NetBIOS over IPX | Client and server: Windows NT Client : MS-DOS, Windows 3.x |
| ncacn_nb_nb | Connection-oriented NetBEUI | Client and server: Windows NT, Windows® 95 Client : MS-DOS, Windows 3.x |
| ncacn_ip_tcp | Connection-oriented TCP/IP | Client and server: Windows 95 and Windows NT Client: MS-DOS,Windows 3.x, and Apple® Macintosh® |
| ncacn_np | Connection-oriented named pipes | Client and server: Windows NT Client: MS-DOS, Windows 3.x, Windows 95 |
| ncacn_spx | Connection-oriented SPX | Client and server: Windows NT, Windows 95 Client: MS-DOS, Windows 3.x |
| ncacn_dnet_nsp | Connection-oriented DECnet | Client only: MS-DOS, Windows 3.x |
| ncacn_at_dsp | Connection-oriented AppleTalk DSP | Server: Windows NT Client: Apple Macintosh |
| ncacn_vns_spp | Connection-oriented Vines SPP | Client and server: Windows NT Client: MS-DOS, Windows 3.x |
| ncadg_ip_udp | Datagram (connectionless) UDP/IP | Client and server: Windows NT Client: MS-DOS, Windows 3.x |
| ncadg_ipx | Datagram (connectionless) IPX | Client and server: Windows NT Client: MS-DOS, Windows 3.x |
| ncalrpc | Local procedure call | Client and server: Windows NT and Windows 95 |
Server has to register its availability to "Name Server" with the last two.
Routine to Sum the integers from 1 to N, shown below:
#include <windows.h>
#include "sum.h" // generated by MIDL compiler (also generates sum_s.c)
long SumUp(short sumVal)
{
short iter;
long theSum;
theSum=0;
for (iter=1; iter<=sumVal; theSum+=iter, iter++);
return(theSum);
}
/*
This program uses an autobinding RPC call to
calculate a running sum.
*/
#include <windows.h>
#include <iostream.h>
#include <rpc.h>
#include <stdlib.h>
#include "sum.h"
#include "memstub" // used by hidden functions in sum.h to allocate/free memory
INT main(VOID)
{
CHAR sumUpToStr[10];
long theSum;
cout << "Enter a value to compute running sum: ";
cin.getline(sumUpToStr, 10);
theSum=SumUp((short)atoi(sumUpToStr));
cout << "The running sum is: " << theSum << endl;
return(0);
}
[
uuid (22449651-4321-1234-4321-987654321CBA), // generated by uuidgen -i (in VC/bin directory)
version(1.0),
endpoint ("ncacn_np:[\\pipe\\autorpc]",
"ncacn_ip_tcp:[1050]") // network connections permitted (can be multiple ones)
]
interface sumup // function names available
{
long SumUp([in] short sumVal); // annotated function prototype
}
[
auto_handle
]
interface sumup
{
}
// autoserv.cpp
#include <windows.h>
#include <iostream.h>
#include <rpc.h>
#include "sum.h"
#include "memstub"
INT main(VOID)
{
RPC_BINDING_VECTOR *bindVector;
// use the protocols specified in the
// IDL file for this interface
if (RpcServerUseAllProtseqsIf(1,
sumup_v1_0_s_ifspec, NULL))
// register the interface
if (RpcServerRegisterIf(sumup_v1_0_s_ifspec,
NULL, NULL))
// get binding handles for the interface
if (RpcServerInqBindings(&bindVector))
// add an entry in the name service
// for the interface
if (RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT,
(UCHAR *) "/.:/autorpc",
sumup_v1_0_s_ifspec, bindVector, NULL))
// listen for and service RPC requests
if (RpcServerListen(1, 5, FALSE))
}
Automatic is easier to code but
inefficient since every RPC call needs to query Name Server
So let's try manual binding or assisted manual.
// conserv.cpp
#include <windows.h>
#include <iostream.h>
#include <rpc.h>
#include "sum.h"
#include "memstub"
INT main(VOID)
{
// use the specified protocol and endpoint
if (RpcServerUseProtseqEp(
(UCHAR *) "ncacn_ip_tcp", 1,
(UCHAR *) "55449", NULL))
// register the interface
if (RpcServerRegisterIf(sumup_v1_0_s_ifspec,
NULL, NULL))
// listen for and service RPC requests
if (RpcServerListen(1, 5, FALSE))
[
implicit_handle(handle_t SumUpHandle)
]
interface sumup
{
}
// conclnt.cpp
/*
This program calls an RPC function
using a manual handle.
*/
#include <windows.h>
#include <iostream.h>
#include <rpc.h>
#include <stdlib.h>
#include "sum.h"
#include "memstub"
INT main(VOID)
{
CHAR sumUpToStr[10];
long theSum;
UCHAR *stringBinding;
cout << "Enter a value to compute running sum: ";
cin.getline(sumUpToStr, 10);
// put together string binding
if (RpcStringBindingCompose(NULL,
(UCHAR *) "ncacn_ip_tcp",
(UCHAR *) "localhost",
(UCHAR *) "55449", NULL, &stringBinding))
// bind to server using string binding info
if (RpcBindingFromStringBinding(stringBinding,
&SumUpHandle))
// free the string binding info
if (RpcStringFree(&stringBinding))
theSum=SumUp((short)atoi(sumUpToStr));
cout << "The running sum is: " << theSum << endl;
// release binding to server
if (RpcBindingFree(&SumUpHandle))