Networking
The BCL includes a number of types that make accessing networked resources easy. Offering different levels of abstraction, these types allow an application to ignore much of the detail normally required to access networked resources, while retaining a high degree of control.
This section describes the core networking support in the BCL, and
provides numerous examples leveraging the predefined classes. The
types mentioned in this section all exist in the
System.Net.RegularExpressions
and
System.Net.Sockets
namespaces.
Network Programming Models
High-level access is performed using a set of types that implement a generic request/response architecture that is extensible to support new protocols. The implementation of this architecture in the BCL also includes HTTP-specific extensions to make interacting with web servers easy.
Should the application require lower-level access to the network, types exist to support the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). Finally, in situations where direct transport-level access is required, there are types that provide raw socket access.
Generic Request/Response Architecture
The request/response architecture is based on Uniform Resource Indicator (URI) and stream I/O, follows the factory design pattern, and makes good use of abstract types and interfaces.
A factory type
(WebRequestFactory
) parses the URI
and creates the appropriate protocol handler to fulfill the request.
Protocol handlers share a common ...
Get C# Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.