NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Using Streams on the Network

The NetworkStream class provides the underlying data stream sent to or received from the network.

You send data to the network using the stream returned by calling GetRequestStream on your WebRequest instance. Data can then be sent to the Internet resource by calling the BeginWrite, EndWrite, or Write methods on the returned stream.

You receive data from the network by calling GetResponseStream on your WebResponse instance. You can then read data from the Internet resource by calling the BeginRead, EndRead, or Read methods on the returned stream.

When using streams from network resources, keep in mind the following points:

// Create a response object
WebResponse response = request.GetResponse;
// Get a readable stream from the server
StreamReader sr = 
   new StreamReader(response.GetResponseStream(), Encoding.ASCII);