本文整理汇总了Python中win32pipe.CreateNamedPipe方法的典型用法代码示例。如果您正苦于以下问题:Python win32pipe.CreateNamedPipe方法的具体用法?Python win32pipe.CreateNamedPipe怎么用?Python win32pipe.CreateNamedPipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32pipe
的用法示例。
在下文中一共展示了win32pipe.CreateNamedPipe方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startPipeServer
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import CreateNamedPipe [as 别名]
def startPipeServer(self, event, wait_time = 0):
openMode = win32pipe.PIPE_ACCESS_DUPLEX
pipeMode = win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_WAIT
sa = pywintypes.SECURITY_ATTRIBUTES()
sa.SetSecurityDescriptorDacl ( 1, None, 0 )
pipe_handle = win32pipe.CreateNamedPipe(self.pipename,
openMode,
pipeMode,
win32pipe.PIPE_UNLIMITED_INSTANCES,
0,
0,
2000,
sa)
threading.Thread(target=self._serverThread, args=(pipe_handle, event, wait_time)).start()
示例2: _create_named_pipe
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import CreateNamedPipe [as 别名]
def _create_named_pipe(template, sids=None):
"""INTERNAL: create a named pipe."""
if sids is None:
sattrs = None
else:
sattrs = _create_security_attributes(*sids)
for i in range(100):
name = template % random.randint(0, 999999)
try:
pipe = CreateNamedPipe(name, PIPE_ACCESS_DUPLEX,
0, 1, 1, 1, 100000, sattrs)
SetHandleInformation(pipe, HANDLE_FLAG_INHERIT, 0)
except WindowsError, e:
if e.winerror != ERROR_PIPE_BUSY:
raise
else:
return pipe, name
示例3: testCompletionPortsNonQueued
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import CreateNamedPipe [as 别名]
def testCompletionPortsNonQueued(self, test_overlapped_death = 0):
# In 204 we had a reference count bug when OVERLAPPED objects were
# associated with a completion port other than via
# PostQueuedCompletionStatus. This test is based on the reproduction
# reported with that bug.
# Create the pipe.
BUFSIZE = 512
pipe_name = r"\\.\pipe\pywin32_test_pipe"
handle = win32pipe.CreateNamedPipe(pipe_name,
win32pipe.PIPE_ACCESS_DUPLEX|
win32file.FILE_FLAG_OVERLAPPED,
win32pipe.PIPE_TYPE_MESSAGE|
win32pipe.PIPE_READMODE_MESSAGE|
win32pipe.PIPE_WAIT,
1, BUFSIZE, BUFSIZE,
win32pipe.NMPWAIT_WAIT_FOREVER,
None)
# Create an IOCP and associate it with the handle.
port = win32file.CreateIoCompletionPort(-1, 0, 0, 0)
win32file.CreateIoCompletionPort(handle, port, 1, 0)
t = threading.Thread(target=self._IOCPServerThread, args=(handle,port, test_overlapped_death))
t.setDaemon(True) # avoid hanging entire test suite on failure.
t.start()
try:
time.sleep(0.1) # let thread do its thing.
try:
win32pipe.CallNamedPipe(r"\\.\pipe\pywin32_test_pipe", str2bytes("Hello there"), BUFSIZE, 0)
except win32pipe.error:
# Testing for overlapped death causes this
if not test_overlapped_death:
raise
finally:
if not test_overlapped_death:
handle.Close()
t.join(3)
self.failIf(t.isAlive(), "thread didn't finish")
示例4: accept_client
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import CreateNamedPipe [as 别名]
def accept_client(self, timeout=None):
"""Blocks until a client connects to the server.
One the client has connected, then the `write` method can be used to write to it.
@param timeout: The maximum number of seconds to wait for the client to connect before raising an
`RedirectorError` exception.
@type timeout: float|None
@return: True if a client has been connected, otherwise False.
@rtype: bool
"""
scaled_timeout = None
if timeout is not None:
scaled_timeout = int(timeout * 1000)
self.__pipe_handle = win32pipe.CreateNamedPipe(
self.__full_pipe_name,
win32pipe.PIPE_ACCESS_OUTBOUND,
win32pipe.PIPE_TYPE_BYTE | win32pipe.PIPE_WAIT,
1,
65536,
65536,
scaled_timeout,
None,
)
return win32pipe.ConnectNamedPipe(self.__pipe_handle, None) == 0
示例5: __init__
# 需要导入模块: import win32pipe [as 别名]
# 或者: from win32pipe import CreateNamedPipe [as 别名]
def __init__(self, pipename=r'\\.\pipe\wireshark'):
self.pipe = win32pipe.CreateNamedPipe(pipename,
win32pipe.PIPE_ACCESS_OUTBOUND,
win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_WAIT,
1, 65536, 65536,
300,
None)
print("Connect wireshark to %s" % pipename)
win32pipe.ConnectNamedPipe(self.pipe, None)
win32file.WriteFile(self.pipe, struct.pack("<LHHLLLL", 0xa1b2c3d4, 2, 4, 0, 0, 65535, LINKTYPE_ETHERNET))