Windows NT ( 2)



         

PIPES - 2


getch();

CloseHandle(hNamedPipe);

return 0;

break;

case ERROR_PIPE_CONNECTED:

fprintf(stdout,

"ConnectNamedPipe: ERROR_PIPE_CONNECTED");

getch();

CloseHandle(hNamedPipe);

return 0;

break;

case ERROR_PIPE_LISTENING:

fprintf(stdout,

"ConnectNamedPipe: ERROR_PIPE_LISTENING");

getch();

CloseHandle(hNamedPipe);

return 0;

break;

case ERROR_CALL_NOT_IMPLEMENTED:

fprintf(stdout,

"ConnectNamedPipe: ERROR_CALL_NOT_IMPLEMENTED");

getch();

CloseHandle(hNamedPipe);

return 0;

break;

default:

fprintf(stdout,"ConnectNamedPipe: Error %ld\n",

GetLastError());

getch();

CloseHandle(hNamedPipe);

return 0;

break;

}

CloseHandle(hNamedPipe);

getch();

return 0;

}

//

fprintf(stdout,"\nConnected. Waiting for command...\n");

//

while(1)

{

// Pipe

if(ReadFile(hNamedPipe, szBuf, 512, &cbRead, NULL))

{

//

//

if(!WriteFile(hNamedPipe, szBuf, strlen(szBuf) + 1,

&cbWritten, NULL))

break;

//

printf("Received: <%s>\n", szBuf);

// "exit",

//

if(!strcmp(szBuf, "exit"))

break;

}

else

{

fprintf(stdout,"ReadFile: Error %ld\n",

GetLastError());

getch();

break;

}

}

CloseHandle(hNamedPipe);

return 0;

}