03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

446 ❘ CHAPTER 20 Networking<br />

Rather than trying to cover all there is to know about network programming in detail, this chapter<br />

explains how to perform these common chores.<br />

If you want to get into network programming, you should look for a book that focuses on just<br />

that. If you search your favorite online bookstore for <strong>C#</strong> Networking, you should find a few good<br />

choices. You can also look at the following articles.<br />

➤ ➤<br />

➤ ➤<br />

➤ ➤<br />

“Network Programming in the .NET Framework” msdn.microsoft.com/<br />

library/4as0wz7t.aspx<br />

“An Introduction to Socket Programming in .NET Using <strong>C#</strong>” www.codeproject.com/<br />

Articles/10649/An-Introduction-to-Socket-Programming-in-NET-using<br />

“Network Programming Samples” msdn.microsoft.com/library/vstudio/ee890485.aspx<br />

Networking Classes<br />

The .NET Framework defines several namespaces containing networking classes. Most of those<br />

namespaces, and some of the most useful classes, are contained in the System.Net namespace.<br />

At the lower levels, the System.Net.Sockets namespace provides classes that manipulate Windows<br />

sockets (Winsock). These let you create and manage sockets, which provide relatively low-level access<br />

to the network. Sockets let you accept incoming connection requests, connect to remote hosts, and<br />

send and receive datagrams.<br />

Datagram<br />

A datagram is a basic unit of data sent over a packet-switched network (a network<br />

that packages data into datagrams). Datagrams may not arrive in the order in which<br />

they were sent.<br />

Typically, a large message might be split into several datagrams that are sent<br />

separately. Higher protocol levels reassemble the datagrams to recover the original<br />

message.<br />

The HttpListener class lets you create a listener that responds to HTTP requests. Using a listener, you<br />

can make a program that runs on a server and responds to incoming requests from other programs.<br />

HTTP<br />

HyperText Transfer Protocol (HTTP) is a protocol that defines how messages<br />

are formatted and transmitted. It sits at a higher level than sockets and datagram<br />

communications.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!