U
    ¸~Hj÷  ã                   @   s”   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ e	ee	e
f dœdd„Zedkr�ee	ejd	 ƒƒ\ZZe  ed
e d ¡ e  e¡ dS )é    N)Úunpack)ÚTuple)Úrecvmsg)ÚsocketfdÚreturnc           	      C   s@   t  | t jt j¡}t|ƒ\}}}|\\}}}td|ƒ\}||fS )az  
    Receive a file descriptor from a L{sendmsg} message on the given C{AF_UNIX}
    socket.

    @param socketfd: An C{AF_UNIX} socket, attached to another process waiting
        to send sockets via the ancillary data mechanism in L{send1msg}.

    @param fd: C{int}

    @return: a 2-tuple of (new file descriptor, description).
    @rtype: 2-tuple of (C{int}, C{bytes})
    Úi)ÚsocketÚfromfdÚAF_UNIXÚSOCK_STREAMr   r   )	r   Z	ourSocketÚdataZ	ancillaryÚflagsZ	cmsgLevelZcmsgTypeZpackedFDZ
unpackedFD© r   ú@/tmp/pip-unpacked-wheel-ewod1tgb/twisted/python/test/pullpipe.pyÚrecvfd   s
    r   Ú__main__é   s   Test fixture data: s   .
)Úosr   ÚsysÚstructr   Útypingr   Ztwisted.python.sendmsgr   ÚintÚbytesr   Ú__name__ÚargvÚfdÚdescriptionÚwriteÚcloser   r   r   r   Ú<module>   s   