Introduction to RPC on Windows: Part I - Meet IDL
(Page 2 of 6 )
If we’re to write applications using RPC on Windows, we must surely be aware of a language that can describe the interface that the server will expose to the client -- basically a channel that sets an agreement between the client and the server. IDL is just that such a thing!
IDL stands for Interface Definition Language. It's a language for defining interfaces to which the client and server should adhere. You might be thinking, "what the heck? A new language just to define interfaces?! Can’t I just make a pure abstract class in C++ and use it?" I too wish that to be true but the fact of life is that the syntax of C or C++ doesn’t allow one to clearly mark a method quite precisely –- I mean in a way that both client and server running across process boundaries, or maybe machine boundaries, may communicate. Fortunately the syntax of IDL is very intuitive and similar to C/C++, and therefore is easy to grasp. So writing an IDL file is somewhat similar to writing a C header file with some added keywords and constructs. IDL is basically an attributed programming language and thus can describe parameters, functions and interfaces in a more precise and descriptive way than C.
Do you “C” the application?
Let’s start with an example so that we grasp the most essential concepts as we encounter them in the process. First we shall take up a simple program and then add to it the Client/Server functionality using RPC. This will let you see clearly the role RPC plays.
// File NoRPC.cpp
using namespace std;
#include <iostream>
// our would be server function.
void Foo(const char* szMsg)
{
std::cout << szMsg << std::endl;
}
int main()
{
// There is no server
// Call local
Foo("I can’t RPC Foo!");
}
This small code fragment does nothing but print ‘I can’t RPC Foo!’ to the console window.
Next: Doing the RPC stuff >>
More .NET Articles
More By Digvijay Chauhan
|
| · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | | |
|