hStream = PIPE sPipeName FOR [ READ ] [ WRITE ] [ WATCH ]
Opens a named pipe for reading, writing or both. If the pipe does not exist it will be automatically created.
A pipe provides unidirectional flow of communication between processes within the same system. In other words, they are half-duplex, that is, data flows in only one direction.
One major feature of a pipe is that the data flowing through the communication medium is transient - data once read from the read descriptor cannot be read again. Also, if we write data continuously into the write descriptor, then we will be able to read the data only in the order in which the data was written.
However, a pipe has to be open at both ends simultaneously before you can proceed to do any input or output operations on it. Opening a pipe for reading normally blocks until some other process opens the same pipe for writing.
Gambas implements a FIFO(First-In, First-out) pipe. For further information look at MKFIFO in the Linux/ Unix manual pages.
![]() | Pipe streams are never buffered. |
Message | Description |
---|---|
Access forbidden (#43) | The requested access to the pipe is not allowed, or search permission is denied for one of the directories in the path prefix of pathname, or write access to the parent directory is not allowed. |
File name was to be created but the device containing Pipe name has no room for the new file. | |
Not a directory (#49) | A component used as a directory in Pipe name is not, in fact, a directory. |
System error... (#42) |
Other possible system errors:
|
' Prints the messages sent to a pipe DIM hFile AS File DIM sLine AS String hFile = PIPE "/tmp/FIFO1" FOR INPUT WHILE NOT Eof(hFile) LINE INPUT #hFile, sLine PRINT sLine WEND Start the above running in one window then do : ls > /tmp/FIFO1