Cover by Ben Albahari, Joseph Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 16. Networking

The Framework offers a variety of classes in the System.Net.* namespaces for communicating via standard network protocols, such as HTTP, TCP/IP, and FTP. Here’s a summary of the key components:

  • A WebClient façade class for simple download/upload operations via HTTP or FTP

  • WebRequest and WebResponse classes for low-level control over client-side HTTP or FTP operations

  • HttpClient for consuming HTTP web APIs and RESTful services

  • HttpListener for writing an HTTP server

  • SmtpClient for constructing and sending mail messages via SMTP

  • Dns for converting between domain names and addresses

  • TcpClient, UdpClient, TcpListener, and Socket classes for direct access to the transport and network layers

Metro applications can access only a subset of these types, namely WebRequest/WebResponse, and HttpClient. However, they can also use WinRT types for TCP and UDP communication in Windows.Networking.Sockets, which we demonstrate in the final section in this chapter.

The .NET types in this chapter are in the System.Net.* and System.IO namespaces.

Network Architecture

Figure 16-1 illustrates the .NET networking types and the communication layers in which they reside. Most types reside in the transport layer or application layer. The transport layer defines basic protocols for sending and receiving bytes (TCP and UDP); the application layer defines higher-level protocols designed for specific applications such as retrieving web pages (HTTP), transferring files (FTP), sending mail (SMTP), and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required