
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Using Named Pipes to Communicate
|
891
This will produce the following output:
Retrieving file from http://localhost/mysite/index.aspx...
Downloaded http://localhost/mysite/index.aspx to C:\Documents and Settings\[user]\
Local Settings\Temp\tmp17C.tmp
Discussion
WebClient simplifies downloading of files and bytes in files, as these are common
tasks when dealing with the Web. The more traditional stream-based method for
downloading can also be accessed via the
OpenRead method on the WebClient.
See Also
See the “WebClient Class” topic in the MSDN documentation.
16.5 Using Named Pipes to Communicate
Problem
You need a way to use named pipes to communicate with another application across
the network.
Solution
Create a P/Invoke wrapper class for the named-pipe APIs in Kernel32.dll. You can
then create a managed client and managed server class to work with named pipes.
Example 16-3 shows the named-pipe interop wrappers in a class called
NamedPipeInterop.
Example 16-3. NamedPipeInterop class
namespace NamedPipes
{
/// <summary>
/// Imported named-pipe entry points for P/Invoke into native code
/// </summary>
public class NamedPipeInterop
{
// #defines related to named-pipe processing
public const int PIPE_ACCESS_OUTBOUND = 0x00000002;
public const int PIPE_ACCESS_DUPLEX = 0x00000003;
public const int ...