当前位置: 首页>>代码示例>>Python>>正文


Python win32pipe.CreateNamedPipe方法代码示例

本文整理汇总了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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_win32pipe.py

示例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 
开发者ID:c-amr,项目名称:camr,代码行数:19,代码来源:winpexpect.py

示例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") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:39,代码来源:test_win32file.py

示例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 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:29,代码来源:platform_windows.py

示例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)) 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:12,代码来源:pcapd.py


注:本文中的win32pipe.CreateNamedPipe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。