diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-02-09 11:54:34 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-02-09 11:57:13 +0100 |
commit | 5438d7dad8d349f8fdc07a89870ddafb9c54a68f (patch) | |
tree | 9c3e178ce24c623732dea20db812d9bb06b3084d /testprogs/win32/npecho/npecho_client2.c | |
parent | 15243c13e914b1ecc6f0eec924cc587a4069c62b (diff) | |
download | samba-5438d7dad8d349f8fdc07a89870ddafb9c54a68f.tar.gz samba-5438d7dad8d349f8fdc07a89870ddafb9c54a68f.tar.bz2 samba-5438d7dad8d349f8fdc07a89870ddafb9c54a68f.zip |
testprogs/win32: add npecho_*2.c
This exlores some details of message type named pipes.
metze
Diffstat (limited to 'testprogs/win32/npecho/npecho_client2.c')
-rwxr-xr-x | testprogs/win32/npecho/npecho_client2.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testprogs/win32/npecho/npecho_client2.c b/testprogs/win32/npecho/npecho_client2.c new file mode 100755 index 0000000000..0486cef28b --- /dev/null +++ b/testprogs/win32/npecho/npecho_client2.c @@ -0,0 +1,48 @@ +/* + * Simple Named Pipe Client + * (C) 2005 Jelmer Vernooij <jelmer@samba.org> + * (C) 2009 Stefan Metzmacher <metze@samba.org> + * Published to the public domain + */ + +#include <windows.h> +#include <stdio.h> + +#define ECHODATA "Black Dog" + +int main(int argc, char *argv[]) +{ + HANDLE h; + DWORD numread = 0; + char *outbuffer = malloc(sizeof(ECHODATA)*2); + + if (argc == 1) { + printf("Usage: %s pipename\n", argv[0]); + printf(" Where pipename is something like \\\\servername\\NPECHO\n"); + return -1; + } + + h = CreateFile(argv[1], GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + if (h == INVALID_HANDLE_VALUE) { + printf("Error opening: %d\n", GetLastError()); + return -1; + } + + Sleep(1000); + + if (!ReadFile(h, outbuffer, sizeof(ECHODATA)*2, &numread, NULL)) { + printf("Error reading: %d\n", GetLastError()); + return -1; + } + + printf("Read: %s %d\n", outbuffer, numread); + + if (!ReadFile(h, outbuffer, sizeof(ECHODATA)*2, &numread, NULL)) { + printf("Error reading: %d\n", GetLastError()); + return -1; + } + + printf("Read: %s %d\n", outbuffer, numread); + + return 0; +} |