320{
321 HANDLE PipeHandle;
324 const int BufferSize = 1024;
325 char BufferToRead[BufferSize] = {0};
326 char BufferToSend[BufferSize] = "test message to send from server !!!";
327
328 printf("create name pipe\n");
330 BufferSize,
331 BufferSize);
332 if (!PipeHandle)
333 {
334
335
336
337 return 1;
338 }
339
340 printf("success!\n");
341 printf("wait for the client connection\n");
342
344 {
345
346
347
348 return 1;
349 }
350
351 printf("client connected\n");
352 printf("read client message\n");
353
354 ReadBytes =
356
357 if (!ReadBytes)
358 {
359
360
361
362 return 1;
363 }
364
365 printf("Message from client : %s\n", BufferToRead);
366
368 PipeHandle,
369 BufferToSend,
370 (int)strlen(BufferToSend) + 1);
371
372 if (!SentMessageResult)
373 {
374
375
376
377 return 1;
378 }
379
381
382 return 0;
383}
UINT32 NamedPipeServerReadClientMessage(HANDLE PipeHandle, char *BufferToSave, int MaximumReadBufferLength)
read client message from the named pipe
Definition namedpipe.cpp:88
BOOLEAN NamedPipeServerSendMessageToClient(HANDLE PipeHandle, char *BufferToSend, int BufferSize)
Definition namedpipe.cpp:123
BOOLEAN NamedPipeServerWaitForClientConntection(HANDLE PipeHandle)
wait for client connection
Definition namedpipe.cpp:58
HANDLE NamedPipeServerCreatePipe(LPCSTR PipeName, UINT32 OutputBufferSize, UINT32 InputBufferSize)
Create a named pipe server.
Definition namedpipe.cpp:27
VOID NamedPipeServerCloseHandle(HANDLE PipeHandle)
Close handle of server's named pipe.
Definition namedpipe.cpp:156