Chapter 15. 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 FTPWebRequest
andWebResponse
classes for more control over client-side HTTP or FTP operationsHttpListener
for writing an HTTP serverSmtpClient
for constructing and sending mail messages via SMTPDns
for converting between domain names and addressesTcpClient
,UdpClient
,TcpListener
, andSocket
classes for direct access to the transport and network layers
The Framework supports primarily Internet-based protocols, although this doesn’t limit applicability to the Internet; protocols such as TCP/IP also dominate local area networks.
The types described in this chapter are defined mostly in the
System.Net
and System.Net.Sockets
namespaces; however,
many of the examples also use types in System.IO
.
Network Architecture
Figure 15-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 converting between domain names and IP addresses (DNS).
Figure 15-1. Network ...
Get C# 4.0 in a Nutshell, 4th Edition 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.