Inter
Process Communication in .NET
Host: Kumar Gaurav Khanna, Microsoft MVP
July
18, 2003
Deepak_MS: Hi Good Evening friends!
Deepak_MS: Today we have with US Kumar Gaurav Khanna, who will talk
about inter-process communication in .NET
Deepak_MS: So lets get started with your questions..
KGK: Good morning and Good evening
KGK: Incase there arent any questions, maybe I will tell
a bit about
KGK: yes... well, IPC, or Interprocess Communication had
its humble beginnings
KGK: from Clipboard and DDE, or the Dynamic Data Exchange
KGK: The idea was simple: in a given application, classes,
functions etc can always get to access shared data. However, what
if the same data needs to be shared with other applications, that
might be part of the main application (like in a client-server architecture)
KGK: or they are not at all related to the main app.
KGK: However, while Clipboard went ahead and solved this
issue to a very limited extent its primary limitation was the fact
that it was restricted to sharing data on the same physcial machine.
KGK: So, an app running on a different machine will not
be able to access Clipboard of another machine.
KGK: Also, DDE had its programming complexity which defeated
the purpose a lot.
KGK: So, maturing with Win32, Windows soon had a better
means of IPC
KGK: 1) Mailslots 2) Pipes (named and anonymous 3) Better
WinSock for socket communication
KGK: These three IPC fundamentals were particularly present
and strong in NT architecture from quite early beginnings..
KGK: 9X architetcure had limited support for the same
- but as time went by... a new dev platform came up...what we now
term as .NET
KGK: And this has brought in some even better IPC communication
mechanisms:
KGK: 1) WebService (ASP.NET and Remoting based)
KGK: 2) Remoting
KGK: 3) Easier and better Socket support
KGK: 4) Clipboard, of-course, is still there
KGK: But does that mean that the previous technologies,
like Pipes, were taken off?
KGK: No way there are alive and kicking.. especially since
high end server products like SQL Server use them to communicate with
their client parts and .NET, though natively doesnt support Pipes,
Mailslots in its FCL implementation,it does support using them via
interop.
KGK: So that rounds up our basics..
Deepak_MS: (ipcs): Will this .NET supports somthing called transport
layer communication which all standard UNIX platforms supports?
KGK: When you talk about Transport layer you are talking
about typical network communication, according to the OSI model
KGK: Yes, the TCP/IP stack is supported, and TCP/UDP protocols
are supported
KGK: natively in the .NET FCL implementation from the
perspective of Transport layer
KGK: Compact Framework, even supports talking with InfraRed
devices using Sockets - at the application layer.
Deepak_MS: (ipc): What are the latest things that got added in .NET
IPC apartt from the standard nes ipcs : is that asp.net (webserver)
something like internet super server daemon in UNIX?
KGK: As I said... .NET has inherent support for TCP/UDP
for IPv4 starting with .NET 1.1, they are also supported over IPv6
KGK: IrDA, via sockets is supprted,
KGK: and starting with Windows Server 2003, the kernel
supports Bluetooth and interacting with such applications/devices
using it.
KGK: Not natively, but via Interop, .NET apps can leverage
that capability too!
KGK: ASP.NET is not a webserver.. IIS is. ASP.NET is simply
a ISAPI plugin..
KGK: something like a server side CGI app, except that
its not CGI and is more advanced and sophisticated.
Deepak_MS: (Anubhav): So whats the Application Domain in .net. its
the same right? which uses the IPC?
KGK: Actually not... Application Domain is a basically
a code execution environment
KGK: that is used to segregate different applications/codes
that need to be executed.
KGK: The idea is that AppDomains will provide an execution
isolation to the code running within them from the code, running in
another AppDomain so that if the latter code crashes for some reason,
code running in other AppDomains isn't affected.
KGK: From the perspective of IPC, AppDomains are boundaries
that need to be surpassed
KGK: for data to be shared between codes executing in
different AppDomains
KGK: for which WebServices, Remoting, sockets, etc can
be used as IPC mechanisms.
Deepak_MS: (SriSamp): Assuming that IPC is an ingrained communication
mechanism for applications, how do applications leverage it?? Are
there any hooks that we can play with??
KGK: IPC is a generic inter-process communication mechanism
KGK: Sockets, Remoting, Pipes, etc are specific ones.
KGK: How do apps. leverage it? Take for instance SQL Server
KGK: When you use the SQL Server Enterprise manager, or
the Query analyzer clients, they connect to the server, either using
Named Pipes or TCP/IP Sockets to get access to the server's shared
configuration and also to talk with the same to send queries and get
the results.
KGK: Done.
Deepak_MS: (ipcs): What's the 4 bone and 6 bone architectures"...???
KGK: http://www.faqs.org/rfcs/rfc2546.html
Deepak_MS: (Kash): Can u tell something about object activation in
Remoting?
KGK: Well, I am talking about Remoting as an IPc mechanism
here but still..
KGK: Object activation basically determines how the object
will be accessed, where it will reside, how TP/RP will come into play.
KGK: Typically, you will have a Server Activated Object
(SAO), or a Client Activated Object (CAO)
KGK: Singlecall and Singleton are examples of SAO...while
in the case Singleton, a single obect constructed in memory is used
to service
KGK: all client requests, the Singlecall object is constructed
and destructed after each method call.
KGK: Thats why, for IPC, or to share some global server
data, Singleton is the way to go.
KGK: For details of remoting architecture, you may want
to read this:
Deepak_MS: (Kash): and also about singleton and singlecall activation?
KGK: My explanation above talks about it.
Deepak_MS: (SriSamp): Any sample .NET code around which demonstrates
how an application can create an IPC with another machine and then
communicate some data across??
KGK: Loads of them any socket code for .NET is an example.
Here's a treasure chest:
KGK: http://www.codeproject.com/csharp/#Internet
Deepak_MS: (ipcs): any nice books for .NET beginers and learning the
architecture...
KGK: hmm.. C# and .NET Platform (APress)
KGK: For Architecture: Essential .NET: The Common Language
Runtime by DonBox