O'Reilly logo

Beginning Microsoft® Visual C#® 2008 by Eric White, Morgan Skinner, Jon D. Reid, Jacob Hammer Pedersen, Christian Nagel, Karli Watson

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

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 and TcpClient

  • 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-1

Figure 32.2. Figure 32-2

Networking can be best illustrated ...

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