Common .NET Framework - Based Network Application Elements


Common .NET FrameworkBased Network Application Elements

Of the namespaces listed in Table 1-1, three base class namespaces focus explicitly on enabling you to develop rich networking scenarios: System.Net , System.Runtime.Remoting , and System.Web.Services . A number of other classes and patterns in the .NET Framework are often useful when it comes to developing applications that interact with the network. This section provides a brief overview of the elements that will be covered in this book and describes why they are often used by network developers.

Input/Output Through Streams

Applications interacting with the network, or with any other resource for that matter, usually need to accomplish one or more of the following:

  • Read input data for the purpose of further processing

  • Write output data for the purpose of further processing by some external entity or by the same application at a later time

The pattern in the .NET Framework for reading and writing data is known as the Stream pattern . As youll see in Chapter 2, the Stream pattern is an incredibly powerful element in the framework because once you learn it, youll know how to make your application interact with nearly any type of resource available to the system on which its running.

Threading and Asynchronous APIs

One commonality among network applications is that they tend to perform tasks that can often be time consuming. Sure, the data can be moving around the world at speeds that are baffling, but even 500 milliseconds can turn into a long delay if not properly handled by the application. Applications must go to great lengths to always act responsively to user input. Have you ever used an application that seemed to freeze or hang as it requested information over the network? If so, you know that this can be a very frustrating experience. The .NET Framework supports two key concepts that, when used properly, help to eliminate the frustration caused by an unresponsive application thats waiting on the network. These concepts are threading and the asynchronous API pattern.

The threading support in the framework makes it easy to perform expensive network operations on a thread other than the main thread of execution, which leaves the main thread free to respond to user input in the case of client applications. For server applications, threading can be fine- tuned to maximize hardware utilization and improve the experience of the client interacting with the server.

The .NET Framework also includes a model for calling methods asynchronously. This option gives you many of the same benefits as threading in that you can make a method call on the main thread of execution and quickly return even if the call is one that would block for a long time if called synchronously. The trick comes in the fact that when you make that asynchronous call, a callback method is supplied. The framework then processes the call on another thread and calls your callback once the work is done. The big difference between the asynchronous pattern and using the threading support directly is that the framework and the underlying CLR thread pool will take care of threading semantics for you in the asynchronous case. All the classes that support asynchronous execution calls follow this common pattern, so if you learn the pattern for one class, you will have learned it for the whole framework. Chapter 3 will walk you through the details behind both of these important elements of the framework.

Serialization

Serialization is the process by which objects are converted from instance format to a serial or stream format that can be sent across the network. Deserialization is the process of converting that same serialized object back into an instance. Serialization can occur through different formats. For example, binary and SOAP are two formats supported by the .NET Framework. Serialization can also involve different transports. For example, using the .NET Framework, a serialized object can be sent from one machine to another over TCP or over HTTP. Both the format and the transport used can have a significant impact on the ability of one node to interoperate with another. Serialization is a key part of building network applications because it forms the basis by which objects are moved from one application instance to another. Chapter 4 will provide you with an in-depth understanding of the core concepts behind serialization and will demonstrate how to best use it in your applications.

System.Uri

Many applications that use the network do so because they want to access resources. To facilitate the naming of resources, the International Engineering Task Force (IETF) created a standard called the URI. URIs are a critical part of network application development because they enable developers to create names for resources that are globally unique. They also enable applications to decouple a resource on the network from the protocol that is used to retrieve that resource. URIs in the .NET Framework are represented by the System.Uri class. Chapter 5 will introduce you to the most common uses of the URI in the .NET Framework and will provide details on key behaviors in System.Uri , such as URI comparison, parsing logic, and best practices.

System.Net

System.Net contains the core networking classes that make up the base transport layer for the .NET Framework. The System.Net namespace includes classes for working with sockets, TCP, UDP, and higher level protocols such as HTTP and File Transfer Protocol (FTP). Chapter 6 introduces the elements of the System.Net namespace and shows how they can be used to build compelling network applications. Chapters 7, 8, and 9 will tell you all that you need to know about using sockets and the Domain Name System (DNS) in the .NET Framework. Chapter 10 covers the details behind the System.Net HTTP implementation.

System.Web.Services

The System.Web.Services namespace contains classes for creating and consuming Web services. Web services are a set of APIs that enable developers to expose a set of functionality to Web users over the SOAP protocol. Using Web services, you can build applications that interact and interoperate with other nodes on the network and scale to Internet proportions . Chapter 11 demonstrates how the Web services implementation in the .NET Framework is layered on top of other technologies covered in this book and how this information can be useful when building your own or consuming other services. Chapter 11 will include the details behind some of the most common network scenarios, such as calling a Web service from inside ASP.NET in the most scalable way, modifying HTTP headers on a Web service call, and fine-tuning the connection limit and other transport- related properties when consuming a service.

System.Runtime.Remoting

System.Runtime.Remoting contains a framework for creating and executing objects in a distributed manner. It has an extensible architecture that lets you plug in just about any element of the stack, from the transport used to manipulate the object to the payload serialization format with which it is represented. Chapter 12 describes the elements of the .NET Remoting architecture that relate to the network and demonstrates how they can be modified and extended to get the most out of .NET Remoting.

Security

Security is critical in a networked world. When designing a networked application, developers must constantly be aware of security because most network programs are made interesting by the data or users that are interacting with them. If either of those elements is compromised, the application becomes less useful at best and highly dangerous at worst. The .NET Framework and the underlying CLR were designed from the ground up with network security in mind. In Chapter 13, well talk about the most common elements of security, such as authentication, authorization, and encryption and how they factor in with the network-related classes in the framework.

Performance

Network applications often include requirements for high performance. Interactive client applications must remain snappy as the user interacts with resources over the network. Server-side content applications need to perform well to serve the maximum number of clients possible in a timely fashion. Network performance can be a complex and challenging space. The .NET Framework does quite a bit to simplify the process of writing high-performance network applications; however, a few key factors should be considered when writing a network application with the .NET Framework to ensure that you get the most out of your client, server, peer, and the network that they use to interact. Chapter 14 covers network performance, including a set of best practices that will help to fine-tune your network applications.

More to Come

Because the .NET Framework is in active development, Microsoft is working on a number of new components related to distributed programming. In Chapter 15, well take a brief look at a number of the exciting trends in network development that are driving this work and discuss ways in which your applications can take advantage of these trends to provide a better user experience. We'll also point out some related areas where we expect to see more support in the framework to help your applications get the most out of the network.




Network Programming for the Microsoft. NET Framework
Network Programming for the MicrosoftВ® .NET Framework (Pro-Developer)
ISBN: 073561959X
EAN: 2147483647
Year: 2003
Pages: 121

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net