File: //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_iocp.cpython-38.pyc
U
W[2 �
@ sJ d Z ddlZddlmZ ddlmZ ddlmZmZmZm Z m
Z
mZ ddlmZ ddl
mZ ddlmZ dd lmZ zPdd
lmZmZmZ ddlmZmZmZ ddlmZ dd
lmZ ddl m!Z! W n e"k
r� dZ#Y nX zeee��$� W n, e
k
�r Z% ze&e%�Z'W 5 dZ%[%X Y nX dZ'G dd� dej(�Z)G dd� dej(�Z*dS )z,
Tests for L{twisted.internet.iocpreactor}.
� N)�array)�pack)�AF_INET6�AF_INET�SOCK_STREAM�
SOL_SOCKET�error�socket)�verifyClass)�unittest)�msg)�
IPushProducer)�iocpsupport�tcp�udp)�IOCPReactor�EVENTS_PER_LOOP�
KEY_NORMAL)�IReadWriteHandle)�SO_UPDATE_ACCEPT_CONTEXT)�
FileHandlez%This test only applies to IOCPReactorc @ s6 e Zd ZdZdd� Zdd� Zdd� Zedk r2ee_dS ) �SupportTestszn
Tests for L{twisted.internet.iocpreactor.iocpsupport}, low-level reactor
implementation helpers.
c
C s> t d|f � t|t�}| �|j� |�d� |�d� t|t�}| �|j� |�d� z|�||� � d f� W n8 t
k
r� } z| �|jtj
tjf� W 5 d}~X Y nX t|t�}| �|j� tdd�}| �dt�|�� |�� |d�� |�tttd |�� �� | �||�� dd
� |� � dd
� ft�|�� |�� dS )a
Create a C{SOCK_STREAM} connection to localhost using a socket with an
address family of C{family} and assert that the result of
L{iocpsupport.get_accept_addrs} is consistent with the result of
C{socket.getsockname} and C{socket.getpeername}.
zfamily = %r)� r � FN�Bs r �P� )r r r Z
addCleanup�closeZbindZlistenZsetblockingZconnectZgetsocknamer ZassertIn�errnoZEINPROGRESSZEWOULDBLOCKr �assertEqual�_iocpZaccept�filenoZ
setsockoptr r r ZgetpeernameZget_accept_addrs)�selfZfamilyZ localhost�portZclient�eZserverZbuff� r% �A/usr/lib/python3/dist-packages/twisted/internet/test/test_iocp.py�_acceptAddressTest( s8
(
� � �zSupportTests._acceptAddressTestc C s | � td� dS )a
L{iocpsupport.get_accept_addrs} returns a three-tuple of address
information about the socket associated with the file descriptor passed
to it. For a connection using IPv4:
- the first element is C{AF_INET}
- the second element is a two-tuple of a dotted decimal notation IPv4
address and a port number giving the peer address of the connection
- the third element is the same type giving the host address of the
connection
z 127.0.0.1N)r'