Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

Named Pipe Examples

20 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Hayes, Jonathan

ungelesen,
02.02.1999, 03:00:0002.02.99
an
Is there any sites I can hit for Python/Win32 Named Pipe examples....bit of
a newbie needing help here!!!

I thankyou in advance.

Jon

Gordon McMillan

ungelesen,
02.02.1999, 03:00:0002.02.99
an
Hayes, Jonathan asks:

> Is there any sites I can hit for Python/Win32 Named Pipe
> examples....bit of a newbie needing help here!!!
>
> I thankyou in advance.

Clipped from a script of mine:
-----------------------------------------------------------
import pywintypes
import win32file
import win32pipe
import winerror

#creating / opening:
if hostnm is None:
pipenm = "\\\\.\\PIPE\\" + pipenm
else:
pipenm = "\\\\"+hostnm+"\\PIPE\\" + pipenm
handle = win32file.CreateFile(
pywintypes.Unicode(pipenm),
win32file.GENERIC_WRITE,
win32file.FILE_SHARE_READ | win32file.FILE_SHARE_WRITE,
None,
win32file.OPEN_EXISTING,
win32file.FILE_ATTRIBUTE_NORMAL ,
0)

#closing:
#sender does this:
win32file.FlushFileBuffers(handle)
#both ends do this:
win32pipe.DisconnectNamedPipe(handle)

#sending:
sent = win32file.WriteFile(handle, msg, None)

#receiving:
b = ''
while (len(b) < minlngth):
try:
(rc, s) = win32file.ReadFile(handle, self.inbuff, None)
b = b + s
except Exception, e:
self.close()
if e[0] == winerror.ERROR_BROKEN_PIPE :
raise EOFError, "Unexpected end of file"
else:
raise
return b
-------------------------------------------------

Like most IPC mechanisms, you'll have to decide on how the receiver
knows it's read the whole message, or you'll end up blocking on a
read that may never return.

"And thru the open window she hands
'Charlie! Your sandwich!'
As the train comes rumblin' through..."

(Hmm, the reference is probably lost on a UK address...)

- Gordon

Ivan Van Laningham

ungelesen,
02.02.1999, 03:00:0002.02.99
an
Hi All--

Gordon McMillan wrote:
>
> Hayes, Jonathan asks:
>

[snip]

> Like most IPC mechanisms, you'll have to decide on how the receiver
> knows it's read the whole message, or you'll end up blocking on a
> read that may never return.
>
> "And thru the open window she hands
> 'Charlie! Your sandwich!'
> As the train comes rumblin' through..."
>
> (Hmm, the reference is probably lost on a UK address...)
>
> - Gordon

Ah, but even someone in the UK can go to their friendly neighborhood
library and ask to see Pete Seeger's autobiography, _The Compleat
Folksinger_, in which the full story is revealed in all its glory (or
ignominy, as the case may be).

<5-cents-more-or-you'll-never-get-off-this-assignment-as-expression-train>-ly
y'rs,
Ivan ;-)
----------------------------------------------
Ivan Van Laningham
Callware Technologies, Inc.
iva...@callware.com
http://www.pauahtun.org
See also:
http://www.foretec.com/python/workshops/1998-11/proceedings.html
----------------------------------------------

0 neue Nachrichten