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: def testread(self): """Read all data currently in pipe.""" while True: try: (nRead, nAvail, nMessage) = win32pipe.PeekNamedPipe(self.hFile, 0) if nAvail: (hr, data) = win32file.ReadFile(self.hFile, nAvail) return data except pywintypes.error, e: errno = e.args[0] if errno == 109: # other end disconnected self.disconnect() self.connect() else: raise It's kind of cool that you can directly port C code to Python, but the end result is IMO nigh-unreadable. p -- http://mail.python.org/mailman/listinfo/python-list