PTC MKS Toolkit Knowledge Base

Product:MKS Toolkit (TKPDev/TKEDev)
Keywords:pipe, FIFO, anonymous pipe
Category:Porting/Knowledge Base

Why does an anonymous pipe hold only about 177 characters?

Win32 pipes are message based. If you create a pipe with a 5120-byte buffer, and write 177 individual characters to the pipe, Win32 prepends a message block to each character (about 28 bytes). (28+1) * 177 = 5133, so the 177th character blocks. Since writes will vary in size, it is possible to write one single 5092 byte (5092+28=5120) byte chunk or 176 one byte writes or various combinations in between. The _NutConf() API and the NUT_PIPE_BUFFER_SIZE environment variable let you tailor the size of anonymous pipes created through the pipe() call.