.NET
  Home arrow .NET arrow Page 3 - Introduction to RPC on Windows: Part I
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Introduction to RPC on Windows: Part I
By: Digvijay Chauhan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 20
    2005-01-10

    Table of Contents:
  • Introduction to RPC on Windows: Part I
  • Meet IDL
  • Doing the RPC stuff
  • Writing Server Side code
  • Writing Client Side Code
  • Points of Interest

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introduction to RPC on Windows: Part I - Doing the RPC stuff


    (Page 3 of 6 )

    Now in order to make the above program use RPC we need to define an interface first that this program may use. So let’s type into a plain text file the interface definition using IDL and save it as DoRPC.idl. I’ll explain the meaning of each line with a comment.

    // File DoRPC.idl
    [
     // A unique identifier that distinguishes this
     // interface from other interfaces.
     uuid(F0C37BD0-0D1B-4513-8C51-EC0D699740C0),

     // This is version 1.0 of this interface.
     version(1.0),

     // This interface will use an implicit binding
     // handle named hDoRPCBinding.
     implicit_handle(handle_t hDoRPCBinding)
    ]

    interface DoRPC  // The interface is named DoRPC
    {
     // A function that takes a zero-terminated string.
    void Show( [in, string] const char* szMsg);
    }

    As a companion to this IDL file we also need to write an Application Configuration File (.acf) with the following text and save it as DoRPC.acf. in the same directory as the IDL file.

    // File DoRPC.acf
    [
       // This interface will use an implicit binding handle named hDoRPCBinding.
       implicit_handle(handle_t hDoRPCBinding)
    ]
    interface DoRPC // The interface is named DoRPC
    {
    }

    Now you may ask the MIDL compiler to generate the source code for you that you may use in your client/server application. To generate the files invoke the tool MIDL.exe as follows:

    MIDL /app_config /no_cpp DoRPC.idl

    If this doesn’t work, you may have to run the vcvars32.bat file to setup the environment variables. This will generate three files for you: DoRPC.h, DoRPC_c.c, and DoRPC_s.c. The files with .c extensions are the source code files generated for the client and server side implementation of the interface; they can be distinguished by the _c and the _s appended to filename. These filenames are, however, configurable through command line switches. This situation can be explained as in the diagram below.

    Introduction to RPC on Windows Part I

    Figure 1: Using the MIDL compiler

    More .NET Articles
    More By Digvijay Chauhan


       · Hi,I was able to compile the *.idl file. But I am getting an error while trying to...
       · i successfully compile the code...but when i running server program i got pop up...
       · First of all I would like to thank you for such wonderful articles on smart card and...
       · You may use the Smart Client like approach to execute Smart Card commands via the...
       · Its very kind of you to respond to my query. We were going through a office move and...
       · It's simple,a C# or J# script would do the job ...... only required thing is...
       · Hi DigvijayThanks very much for the response, but I am still struggling how to...
       · Hi,I believe i conveyed something wrong.What i meant was ........ after...
       · I am so sorry, this is my first ever attempt on .net and I am still not quite sure ...
       · First ..... You need not register the script if you have it running on the client...
       · I think I now understand whats happening.This is my latest codeprivate void...
       · Dear Friend,You've done it finally.Just enable Smart Clients on the client...
       · Hithanks for good article.I have some problem with MIDLhow I can get...
       · I am not able to compile the server code its stating that the function does not...
       · I am not able to compile the server code its stating that the function does not...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT