Srijit Kumar Bhadra wrote:
> Hello,> Here is an example of Multithreaded Pipe Server and Client using the> excellent ctypes library (Windows).
Coincidentally, the other day I just used named pipes in for the first
time. I recommend using the excellent win32api extension; I believe it
is included by deafult in the ActiveState distro.
The API calls look fairly similar, but you pass strings instead of
c_whatever_p(), they return tuples, and they throw exceptions instead
of returning HRESULT h s.t. FAILED(h). The resulting code feels much
more Pythonic. For example, my first test looked like this:
"""Read all data currently in pipe."""
(nRead, nAvail, nMessage) =
(hr, data) = win32file.ReadFile(self.hFile, nAvail)
except pywintypes.error, e:
errno = e.args
if errno == 109: # other end disconnected
It's kind of cool that you can directly port C code to Python, but the
end result is IMO nigh-unreadable.