Win32-2.14.1.0: A binding to Windows Win32 API.
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Win32.NamedPipes

Description

For full details on the Windows named pipes API see https://docs.microsoft.com/en-us/windows/desktop/ipc/named-pipes

Synopsis

Named pipe server APIs

createNamedPipe Source #

Arguments

:: String

A unique pipe name of the form \.pipe{pipename} The pipename part of the name can include any character other than a backslash, including numbers and special characters. The entire pipe name string can be up to 256 characters long. Pipe names are not case sensitive.

-> OpenMode 
-> PipeMode 
-> DWORD

nMaxInstances

-> DWORD

nOutBufferSize

-> DWORD

nInBufferSize

-> DWORD

nDefaultTimeOut

-> Maybe LPSECURITY_ATTRIBUTES 
-> IO HANDLE 

Creates an instance of a named pipe and returns a handle for subsequent pipe operations. A named pipe server process uses this function either to create the first instance of a specific named pipe and establish its basic attributes or to create a new instance of an existing named pipe.

For full details see https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-createnamedpipea

To create a named pipe which can be associate with IO completion port on needs to pass fILE_FLAG_OVERLAPPED to OpenMode argument, e.g.

 Win32.createNamedPipe pipeName
                       (pIPE_ACCESS_DUPLEX .|. fILE_FLAG_OVERLAPPED)
                       (pIPE_TYPE_BYTE .|. pIPE_READMODE_BYTE)
                       pIPE_UNLIMITED_INSTANCES
                       512
                       512
                       0
                       NothinROR

Parameter types

type OpenMode = UINT Source #

The named pipe open mode.

This must specify one of:

It may also specify:

It may also specify any combination of:

type PipeMode = UINT Source #

The pipe mode.

One of the following type modes can be specified. The same type mode must be specified for each instance of the pipe.

One of the following read modes can be specified. Different instances of the same pipe can specify different read modes.

One of the following wait modes can be specified. Different instances of the same pipe can specify different wait modes.

One of the following remote-client modes can be specified. Different instances of the same pipe can specify different remote-client modes.

  • pIPE_ACCEPT_REMOTE_CLIENT
  • pIPE_REJECT_REMOTE_CLIENT

pIPE_ACCEPT_REMOTE_CLIENTS :: PipeMode Source #

If the createNamedPipe nMaxInstances parameter is pIPE_UNLIMITED_INSTANCES, the number of pipe instances that can be created is limited only by the availability of system resources.

Named pipe client APIs

connect to a named pipe

connect Source #

Arguments

:: String

file name

-> AccessMode

dwDesiredAccess

-> ShareMode

dwSharedMode

-> Maybe LPSECURITY_ATTRIBUTES

lpSecurityAttributes

-> CreateMode

dwCreationDisposition

-> FileAttributeOrFlag

dwFlagsAndAttributes

-> Maybe HANDLE

hTemplateFile

-> IO HANDLE 

A reliable connect call, as designed in https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipe-client

The arguments are passed directly to createFile.

Note we pick the more familiar posix naming convention, do not confuse this function with connectNamedPipe (which corresponds to posix accept)

waiting for named pipe instances

waitNamedPipe Source #

Arguments

:: String

pipe name

-> TimeOut

nTimeOut

-> IO Bool 

Wait until a named pipe instance is available. If there is no instance at hand before the timeout, it will error with ERROR_SEM_TIMEOUT, i.e. invalid argument (The semaphore timeout period has expired)

It returns True if there is an available instance, subsequent createFile might still fail, if another thread will take turn and connect before, or if the other end shuts down the name pipe.

It returns False if timeout fired.

type TimeOut = DWORD Source #

Timeout in milliseconds.