2 * Simple Named Pipe Client
3 * (C) 2005 Jelmer Vernooij <jelmer@samba.org>
4 * (C) 2009 Stefan Metzmacher <metze@samba.org>
5 * Published to the public domain
11 #define ECHODATA "Black Dog"
13 int main(int argc, char *argv[])
17 char *outbuffer = malloc(sizeof(ECHODATA)*2);
20 printf("Usage: %s pipename\n", argv[0]);
21 printf(" Where pipename is something like \\\\servername\\NPECHO\n");
25 h = CreateFile(argv[1], GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
26 if (h == INVALID_HANDLE_VALUE) {
27 printf("Error opening: %d\n", GetLastError());
33 if (!ReadFile(h, outbuffer, sizeof(ECHODATA)*2, &numread, NULL)) {
34 printf("Error reading: %d\n", GetLastError());
38 printf("Read: %s %d\n", outbuffer, numread);
40 if (!ReadFile(h, outbuffer, sizeof(ECHODATA)*2, &numread, NULL)) {
41 printf("Error reading: %d\n", GetLastError());
45 printf("Read: %s %d\n", outbuffer, numread);