.NET
  Home arrow .NET arrow Page 5 - Introduction to RPC on Windows, Part II
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 II
By: Digvijay Chauhan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2005-01-17

    Table of Contents:
  • Introduction to RPC on Windows, Part II
  • Types of Handles
  • Types of Binding Handles
  • Implicit binding handles
  • Explicit binding handles

  • 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 II - Explicit binding handles


    (Page 5 of 5 )

    Finally, Explicit binding handles allow for maximum control over the binding process. Client/server applications may benefit greatly from using explicit binding handles. Just as with implicit handles, explicit binding handles also enable your client application to select a server to execute calls for it, apart from enabling your client/server application to create an authenticated RPC communication session. When using explicit handles, your client may connect to more than one server at the same time and execute remote procedures on any of them one at a time. If the client is multithreaded and asynchronous, it can choose to connect to multiple servers and execute multiple remote procedures at the same time. We shall learn about the asynchronous mode of RPC in the next article.

    But here the client needs to pass the explicit binding handle (it is mandatory!) as a parameter to each remote procedure call it makes and defines in the MIDL interface. With MS RPC, the handle is always the first parameter on each of remote procedures invoked. But depending on your requirements you may use the Microsoft extensions to RPC to specify the binding handle in other positions.

    In order to create an explicit handle, declare the handle as a parameter to the remote calls in the IDL file. The Hello, World example can be redefined to use an explicit handle as shown:

    /* IDL file for explicit handles */
    [
      uuid(2CBD1C41-8292-4bcc-B0E8-54145A626433),
      version(1.0)

      // Note that no handle here
    ]

    interface IMine
    {
      void Foo([in] handle_t hExplicit,
                     [in, string] int*  pVal);
    }

    You can always choose to mix explicit and implicit handles in a single interface depending on your needs. A very simple rule is followed here: if a function consumes an explicit handle as its parameter, that handle will be used, otherwise the default implicit handle will be used.

    Using Context and Binding Handles in your Applications

    Based on the above conditions you may use a binding handle in your own application and create/modify the interfaces appropriately. You must also modify the ACF file for using a particular type of binding handle because MIDL generates code based on not just the IDL but the ACF file as well. Personally, I still don’t understand the need for a separate file when this information itself could be inserted in the IDL; ij any case, it’s not a matter of concern.

    Now we’re all set to write a full fledged RPC app and shall do so in the next article.

    Oh, one final note: if the server becomes unavailable or crashes, the client application should call the function RpcSmDestroyClientContext to free its context data.

    Summary

    Context and Binding handles in RPC are very powerful tools and they let us unleash their power in the way we want. They allow for developing object oriented and modular applications with RPC. As we have seen in the theory above, an object on the server can be tokenized to a context handle on the client, and using this encapsulation, the implementation of an object on the client can simply map functions directly to the server, by using context handles. But these are just the basics (really) and we shall see some code in execution (rather action) in the next article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hi I'm Digvijay ....... the author of this article.Please feel free to ask any...
       · I do like your explaination on the topic of RPC. I try to used them to solve...
       · Thank you for your article. I am having a problem where the sever denies access to...
       · Hi,I didn't get what you're trying to solve. Could you please give me the...
       · What is the exact error do you get?Would you like me to take a look at the...
     

    .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

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




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