Full Duplex Pipes Programming Interface
3-34
3.4
Full Duplex Pipes Programming Interface
3.4.1
Synopsis
Although sockets can be used for inter-task communications, it is not the most
efficient method. The stack provides a second data communications model
called pipes, which allow for local connection oriented communications.
A pipe is a full duplex connection oriented file descriptor. When a pipe is
created, both ends of the pipe are returned to the caller as file descriptors. One
end of the pipe can then be passed to another task by first converting it to a
file handle with the fdGetFileHandle() function.
Communications is performed using the standard file and sockets API func-
tions. All the file descriptor functions are supported with pipes: fdSelect(),
fdClose(), fdError(), and fdGetFileHandle().
Also, socket functions send() and recv() are used to write and read data
through the pipe. Both functions also support the following standard sockets
message flags when using pipes:
MSG_PEEK
Examine data but don’t consume it.
MSG_DONTWAIT
Don’t block on send/recv operation (by default, pipe
operations always block).
Pipes are connection oriented, thus when one end closes the other end is al-
tered by an error return from send() or recv(). It is therefore possible to make
a blocking call on recv() without concern that the function will be deadlocked
if the other end terminates the connection.