Chapter 32. Networking
Chapter 21 dealt with a high-level technology to communicate across the network: Web Services. You learned how to send messages from the client to the server in a platform-independent way with the SOAP and .NET-specific protocols. In this chapter, you step into lower networking layers, programming with classes from the namespace System.Net
. Web Services itself uses this technology.
This chapter begins with an overview of programming client and server applications with classes from the namespaces System.Net
and System.Net.Sockets
, which make use of protocols such as HTTP, TCP, and UDP. You explore both connection-oriented applications with TCP and connectionless applications with the UDP protocol.
This chapter includes the following topics:
An overview of networking
Networking programming options
Using
WebRequest
TcpListener
andTcpClient
Socket programming
Networking Overview
Networking is about communicating with applications on other systems. The communication happens by sending messages. Messages can be sent to a single system where a connection is initiated before the message, as shown in Figure 32-1, or messages can be sent to multiple systems by a broadcast, as shown in Figure 32-2. With a broadcast, connections are not initiated; the messages are just sent to the network instead.
Figure 32.1. Figure 32-1
Figure 32.2. Figure 32-2
Networking can be best illustrated ...
Get Beginning Microsoft® Visual C#® 2008 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.