-#ifdef WIN32
- string name = format("\\\\.\\pipe\\%u.%p", GetCurrentProcessId(), this);
- handle[0] = CreateNamedPipe(name.c_str(), PIPE_ACCESS_INBOUND|FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE, 1, 1024, 1024, 0, 0);
- if(handle[0]==INVALID_HANDLE_VALUE)
- throw SystemError("Unable to create pipe", GetLastError());
-
- handle[1] = CreateFile(name.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
- if(handle[1]==INVALID_HANDLE_VALUE)
- {
- unsigned err = GetLastError();
- CloseHandle(handle[0]);
- throw SystemError("Unable to create pipe", err);
- }
-
- overlapped = 0;
- event = CreateEvent(0, true, false, 0);
- buf_size = 1024;
- buffer = new char[buf_size];
- buf_avail = 0;
- buf_next = buffer;
-#else
- if(pipe(handle)==-1)
- throw SystemError("Unable to create pipe", errno);
-#endif