WIN32 Named Pipes API - Access Module

Teradata Tools and Utilities Access Module Reference

Product
Access Module
Release Number
15.00
Language
English (United States)
Last Update
2018-09-27
dita:id
B035-2425
lifecycle
previous
Product Category
Teradata Tools and Utilities

WIN32 Named Pipes API

When creating a Win32 client application that writes to a named pipe, it is necessary to know how the named pipes server creates the named pipe. This is important to be able to code the corresponding options on the client application's CreateFile() system call.

The Win32 Named Pipes Access Module creates the named pipe using the following system call:

CreateNamedPipe(PipeName, // Pipe name
                     PIPE_ACCESS_INBOUND, // Open mode
                     PIPE_TYPE_BYTE,      // pipe mode
                     4,            // Number of instances
                     BuffSize,     // output buffer size
                     BuffSize,    // input buffer size
                     100,// default timeout in milliseconds
                     NULL); // pointer to security attributes

where:

PipeName is any string of the form \\.\pipe\pipename and pipename is the pipe name agreed upon between the client and server applications and BuffSize is a value that is twice the number of bytes specified in the initialization string “Block_size” parameter.

A user‑developed client application must code the GENERIC_WRITE (but not the GENERIC_READ) option on its CreateFile() system call because the access module allows data to flow only from client to server.

Example  

   HANDLE hPipe = 
   CreateFile(PipeName,// pipe name 
     GENERIC_WRITE,// write access
     0,              // no sharing 
     NULL,           // no security attributes
     OPEN_EXISTING,  // opens existing pipe 
     0,              // default attributes 
     NULL);          // no template file 

Alternately, the client utility can use standard `C' stream I/O, opening the pipe with the following:

   FILE *fp = fopen(PipeName, "wb");

As a named pipes server, the access module both connects to the pipe and reads from the pipe using synchronous, blocking I/O. The client is free to write to the pipe either synchronously or asynchronously.

The access module does not impose a message structure on the data flowing through the pipe. Thus, the client application may write to the named pipe either as a stream of bytes or as a stream of messages since the access module always reads from the pipe as a stream of bytes.

For details on programming Win32 named pipes, see the article “Named Pipes” under Platform SDK in the Microsoft Developer's Network OnLine Library.