我的多线程应用程序运行良好,除了以下情况:最初我从管道中读取 16 个字节,然后根据标题读取其余部分。
问题是有时客户端会写一条消息(比如 300 字节长)然后关闭连接。
我的服务器收到前 16 个字节,然后决定获取其余 284 个字节,但 ReadFile 返回错误 233(管道另一端没有进程。)
那么,这 284 个字节到哪里去了?我想它们应该在管道缓冲区或其他东西中。
像通常在网络上的所有示例中一样创建的管道:
 HANDLE h= CreateNamePipe(
    name,                  // pipe name
    PIPE_ACCESS_DUPLEX |        // read/write access
    FILE_FLAG_OVERLAPPED,       // overlapped mode
    PIPE_TYPE_MESSAGE |         // message-type pipe
    PIPE_READMODE_MESSAGE |     // message read mode
    PIPE_WAIT,                  // blocking mode
    PIPE_UNLIMITED_INSTANCES,   // unlimited instances
    100000,                   // output buffer size
    100000,                   // input buffer size
    0,               // client time-out
    lpSecurityAttributes);                     // default security attributes