O'Reilly logo

Professional C# 6 and .NET Core 1.0 by Christian Nagel

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

25 Networking

What’s In This Chapter?

  • Using HttpClient
  • Manipulating IP addresses and performing DNS lookups
  • Creating a server with WebListener
  • Socket programming with TCP, UDP, and socket classes

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at http://www.wrox.com/go/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • HttpClientSample
  • WinAppHttpClient
  • HttpServer
  • Utilities
  • DnsLookup
  • HttpClientUsingTcp
  • TcpServer
  • WPFAppTcpClient
  • UdpReceiver
  • UdpSender
  • SocketServer
  • SocketClient

Networking

This chapter takes a fairly practical approach to networking, mixing examples with a discussion of relevant theory and networking concepts as appropriate. This chapter is not a guide to computer networking but an introduction to using the .NET Framework for network communication.

This chapter shows you how to create both clients and servers using network protocols. It starts with the simplest case: sending an HTTP request to a server and storing the information that’s sent back in the response.

Then you see how to create an HTTP server, using utility classes to split up and create URIs and resolve hostnames to IP addresses. You are also introduced to sending and receiving data via TCP and UDP and find out how to make use of the Socket class.

The two namespaces of most interest for networking are System.Net and System.Net.Sockets. The System.Net namespace is generally concerned ...

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