Network Programming in .NET: With C# and Visual Basic .NET

4.4: System.Net.HttpWebListener

4.4 System.Net.HttpWebListener

In .NET 2 Whidbey, a more elegant solution for implementing Web servers exists, namely the HttpWebListener class. This class leverages the Http.sys driver (where available) to deliver unprecedented performance, and integrates many features, such as SSL encryption and authentication, which would be difficult to develop from the ground up.

The HttpWebListener class consists of the significant methods and properties shown in Table 4.7.

Table 4.7: Significant members of the HttpWebListener class .

Method or Property

Description

Abort / Close

Destroys the request queue.

AddPrefix

Adds a prefix to the Web listener.

BeginGetRequest

Awaits a client request asynchronously. Returns IasyncResult.

EndGetRequest

Handles client request. Returns ListenerWebRequest.

GetPrefixes

Retrieves all handled prefixes. Returns String[]v.

GetRequest

Awaits a client request synchronously. Returns ListenerWebRequest.

RemoveAll

Removes all prefixes.

RemovePrefix

Removes a specified prefix.

Start

Starts the Web server.

Stop

Stops the Web server.

AuthenticationScheme

Sets the means by which the server authenticates clients. Returns AuthenticationScheme (i.e., Basic, Digest, NTLM).

IsListening

Determines if the server is running. Returns Boolean.

Realm string

If Basic or Digest authentication schemes are selected, gets the realm directive. Returns String.

The ListenerWebRequest returned by GetRequest contains the significant methods and properties shown in Table 4.8.

Table 4.8

Method or Property

Description

Abort / Close

Closes the client connection.

GetRequestStream

Retrieves a reference to the stream sent from the client. Returns Stream.

GetResponse

Retrieves a reference to the response to be sent to the client. Returns ListenerWebResponse.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Computer Terminals
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.