Named Pipes, Sockets, and P2P
As if choosing among DCOM, .NET remoting, web services, COM+, and MSMQ was not challenging
enough, the list of distributed APIs continues. Programmers can also make use of additional inter-
process communication APIs such as named pipes, sockets, and peer-to-peer (P2P) services. These
lower-level APIs typically provide better performance (especially for machines on the same LAN);
however, using these APIs becomes more complex (if not impossible) for outward-facing applica-
tions.
If you are building a distributed system involving a set of applications running on the same
physical machine, you can make use of the named pipes API via the System.IO.Pipes namespace
(which is new to .NET 3.5). This approach can provide the absolute fastest way to push data
between applications on the same machine.
As well, if you are building an application that requires absolute control over how network
access is obtained and maintained, sockets and P2P functionality can be achieved under the .NET
platform using the System.Net.Sockets and System.Net.PeerToPeer namespaces, respectively.
The Role of WCF
As I am sure you already figured out from the previous few pages, the wide array of distributed tech-
nologies makes it very difficult to pick the right tool for the job. This is further complicated by the
fact that several of these technologies overlap in the services they provide (most notably in the areas
of transactions and security).
Even when a .NET developer has selected what appear to be the “correct” technologies for the
task at hand, building, maintaining, and configuring such an application is complex at best. Each
API has its own programming model, its own unique set of configuration utilities, and so forth.
Because of this, prior to .NET 3.0, it was very difficult to “plug and play” distributed APIs with-
out authoring a considerable amount of custom infrastructure. For example, if you build your
system using the .NET remoting APIs, and you later decide that XML web services are a more appro-
priate solution, you need to reengineer your code base.
WCF is a distributed computing toolkit introduced with .NET 3.0 that integrates these previous
independent distributed technologies into a streamlined API represented primarily via the System.
ServiceModel namespace. Using WCF, you are able to expose services to callers using a wide variety
of techniques. For example, if you are building an in-house application where all connected
machines are Windows based, you can make use of various TCP protocols to ensure the fastest
possible performance. This same service can also be exposed using the XML web service–based
protocol to allow external callers to leverage its functionality regardless of the programming lan-
guage or operating system.
C H A P T E R 2 5
Do'stlaringiz bilan baham: |