AKA Server detects error, sends the error message to the server message board to output to console screen.
Server
C++ Syntax (Toggle Plain Text)
- HANDLE _pipeRead;
- HANDLE _pipeWrite;
- SECURITY_ATTRIBUTES sa;
- sa.nLength = sizeof(SECURITY_ATTRIBUTES);
- sa.bInheritHandle = true;
- sa.lpSecurityDescriptor = 0;
- if(!CreatePipe(&_pipeRead, &_pipeWrite, &sa, 0))
- {
- int error = GetLastError();
- std::cout << GetLastError();
- }
- PROCESS_INFORMATION pi;
- STARTUPINFO si;
- ZeroMemory(&si,sizeof(STARTUPINFO));
- si.cb = sizeof(STARTUPINFO);
- si.dwFlags = STARTF_USESTDHANDLES;
- si.hStdOutput = _pipeRead;
- si.hStdInput = _pipeWrite;
- si.hStdError = _pipeWrite;
- if(!CreateProcess("Child.exe", 0, 0, 0, true, CREATE_NEW_CONSOLE, 0, 0, &si, &pi))
- {
- int error = GetLastError();
- std::cout << "Error: " << error;
- }
- while(true)
- {
- DWORD bytesSent = 0;
- WriteFile(_pipeWrite, "Test Message", strlen("Test Message"), &bytesSent, 0);
- }
Server message board
C++ Syntax (Toggle Plain Text)
- char msgBuffer[25];
- DWORD bytesRead = 0;
- while(true)
- {
- ReadFile(GetStdHandle(STD_INPUT_HANDLE), msgBuffer, 25, &bytesRead, 0);
- printf(msgBuffer);
- }
I would expect that I would see the message "Test Message" being repeated on the Server Message Board console.
Can anyone clear things up?