4.12. Network Class Libraries

All classes in the System.Net namespace have improved stability and performance. Standards compliance has been improved for FTP, HTTP, SMTP, and URIs, with better support for internationalization.

NOTE

At the time of writing, little information is available about these changes, so I apologize for the lack of detail.

4.12.1. IPv6 Support

Applications running on Vista onward can now handle multiple versions of the IP protocol (v4 and v6) by setting the IPv6Only option to false when creating the socket.

4.12.2. HttpWebRequest

HttpWebRequest has had two new properties added:

  • Date, for setting the HTTP date header

  • Host, for setting the HTTP host header (this can be useful for testing load balancing scenarios to test the connection to a particular server)

Examples of these properties are as follows:

string loadbalancerIp = "http://127.0.0.1/";
string host = "mywebsite.com";
var request = WebRequest.Create("http://127.0.0.1/") as HttpWebRequest;
request.Date = System.DateTime.Now;

Support has also been added in HttpWebRequest.AddRange() for int64 ranges.

4.12.3. DnsEndPoint

DnsEndPoint is a new class that allows you to create a socket connection by specifying a FQDN name without making a call to Dns.GetHostAddresses(), resulting in reduced and clearer code—for example:

var socket = new System.Net.Sockets.Socket(new System.Net.Sockets.SocketInformation());
socket.Connect(new DnsEndPoint("www.microsoft.com", 80));

4.12.4. Default SSL Policy

For interoperability, it is sometimes necessary to turn off SSL encryption (a null cipher). HttpWebRequest, FtpWebRequest, and SmtpClient now allow you to use a null cipher by specifying it using the System.Net.Security.EncryptionPolicy enum or in Web/machine.config:

4.12.5. SMTP Client

The SMTP client contains a number of useful enhancements:

  • Enabling SSL mode in application config files

  • Specifying heading encoding

  • Multiple replying to addresses through MailMessage.ReplyToList()

4.12.6. TCPListener Support for NAT Transversal

Many applications are located behind a firewall, which can cause complications when communicating with them. One way around this is network address translation (NAT) transversal, which takes care of various complications. In .NET 4.0, NAT transversal support has been added to TcpListener and UdpClient.

4.12.7. WebRequest

New performance counters have been added for WebRequest:

  • HttpWebRequests created/sec

  • HttpWebRequests queued/sec

  • HttpWebRequests aborted/sec

  • HttpWebRequests failed/sec

  • HttpWebRequest average lifetime

  • HttpWebRequests' average queue time

You can review the diagram shown here to see where they occur in a request lifetime: http://blogs.msdn.com/blogfiles/ncl/WindowsLiveWriter/NewNCLFeaturesin.NET4.0Beta2_78A0/image_2.png.

4.12.8. Windows 7 Only

.NET 4.0 has some new features that are available only for Windows 7 machines.

4.12.8.1. System.Device.Location

.NET 4.0 contains a new API for querying Windows 7's location functionality. The Location class supports multiple devices such as GPS and wireless wide area network (WWAN—wireless by cellular phone technology). It returns the current latitude, longitude, altitude, horizontal and vertical accuracy, course, speed, and civic address (country/region, state/province, city, postal code, street, building, and floor level, if available). At the time of writing, the Network Class Library (NCL) team is currently refactoring these libraries.

4.12.8.2. ExtendedProtection

Windows 7 introduces enhanced security features to prevent replay network attacks. Classes in System.Net and related namespaces such as HttpWebListener, HttpWebRequest, NegotiateStream, SmtpClient, and SSLStream will now utilize these enhancements by default when Windows authentication is used. For the nitty-gritty full details of these changes, consult http://msdn.microsoft.com/en-us/library/dd582691(VS.100).aspx.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.11.247