U
    
W[Ä  ã                   @   sx   d dl Z d dlZd dlZd dlmZ d dlmZ dd„ Zedkrtee	e j
d ƒƒ\ZZe ede d	 ¡ e e¡ dS )
é    N)Úunpack)Úrecvmsgc           	      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)ÚsocketZfromfdZAF_UNIXZSOCK_STREAMr   r   )	ZsocketfdZ	ourSocketÚdataZ	ancillaryÚflagsZ	cmsgLevelZcmsgTypeZpackedFDZ
unpackedFD© r   ú>/usr/lib/python3/dist-packages/twisted/python/test/pullpipe.pyÚrecvfd   s
    r
   Ú__main__é   s   Test fixture data: s   .
)ÚsysÚosr   Zstructr   Ztwisted.python.sendmsgr   r
   Ú__name__ÚintÚargvÚfdZdescriptionÚwriteÚcloser   r   r   r	   Ú<module>   s   