libmoost
|
00001 /* vim:set ts=3 sw=3 sts=3 et: */ 00028 #ifndef MOOST_IO_DETAIL_ASYNC_STREAM_FORWARDER_WIN32_HPP__ 00029 #define MOOST_IO_DETAIL_ASYNC_STREAM_FORWARDER_WIN32_HPP__ 00030 00031 #include <windows.h> 00032 00033 namespace moost { namespace io { namespace detail { 00034 00035 class forwarding_loop 00036 { 00037 public: 00038 void stop() const 00039 { 00040 // nothing to do 00041 } 00042 00043 void run(HANDLE from, HANDLE to) const 00044 { 00045 char input; 00046 LPVOID inbuf = reinterpret_cast<LPVOID>(&input); 00047 DWORD dummy; // we don't care; we know it's one byte if it succeeded 00048 00049 while (ReadFile(from, inbuf, 1, &dummy, NULL) && 00050 WriteFile(to, inbuf, 1, &dummy, NULL)) 00051 { 00052 } 00053 } 00054 }; 00055 00056 } } } 00057 00058 #endif