Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- const char nome[] = R"(\\.\pipe\pippo)";
- int main(int argc, char* argv[]) {
- HANDLE hpipe;
- BOOL bRet;
- DWORD size;
- hpipe = CreateFile(nome, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
- if (hpipe == INVALID_HANDLE_VALUE) {
- std::cerr << "Errore apertura file: " << GetLastError() << "\n";
- }
- while (true) {
- char messaggio[100];
- bRet = ReadFile(hpipe, messaggio, 100, &size, NULL);
- if (bRet == FALSE) {
- std::cerr << "Lettura fallita: letti " << size << " byte.\n";
- break;
- }
- std::cout << "Ricevuto dal server: " << messaggio << "\n";
- Sleep(500);
- }
- CloseHandle(hpipe);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement