
H!Nc           @   s{  d  Z  d d l Z d d l Z 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 m Z y  d d l m Z m Z m Z Wn e k
 r!y  d d l m Z m Z m Z Wq"e k
 rd e f d     YZ d	 e f d
     YZ d e f d     YZ q"Xn Xe	 d k re   Z d d l m Z d d l m Z d d l m Z d d l m Z  d d l m! Z" d d l m# Z$ d d l m% Z& d d l m' Z( d d l m) Z* d d l m+ Z, e   Z- e   Z. e Z/ d d l m! Z0 d d l1 m2 Z3 n d d l m Z d d l m Z d d l m Z d d l m Z d d l m  Z  d d l m" Z" d d l m$ Z$ d d  l m& Z& d d! l m( Z( d d" l m* Z* d d# l m, Z, d d$ l m- Z- d d% l m. Z. d d& l m/ Z/ d d' l m0 Z0 d d( l4 m3 Z3 d d) l m5 Z5 d d* l6 m7 Z7 m8 Z8 m9 Z9 d d+ l: m; Z; d d, l
 m< Z< m= Z= m> Z> d d- l? m@ Z@ d d. lA mB ZB d d/ l6 mC ZC mD ZD mE ZE mF ZF d0 e f d1     YZG d2 e f d3     YZH d4 e eC jI eG eH f d5     YZJ d6 e eJ f d7     YZK d8 eK f d9     YZL d: e eJ f d;     YZM d< e7 jN eG f d=     YZO d> e7 jP f d?     YZQ d S(@   st   
Various asynchronous TCP/IP classes.

End users shouldn't use this module directly - use the reactor APIs instead.
iN(   t
   implements(   t   platformType(   t   versionst	   deprecate(   t   ConnectionMixint   ClientMixint   ServerMixint   _TLSConnectionMixinc           B   s   e  Z e Z RS(    (   t   __name__t
   __module__t   Falset   TLS(    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   )   s   t   _TLSClientMixinc           B   s   e  Z RS(    (   R   R	   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   +   s   t   _TLSServerMixinc           B   s   e  Z RS(    (   R   R	   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   -   s   t   win32(   t	   WSAEINVAL(   t   WSAEWOULDBLOCK(   t   WSAEINPROGRESS(   t   WSAEALREADY(   t   WSAECONNRESET(   t
   WSAEISCONN(   t   WSAENOTCONN(   t   WSAEINTR(   t
   WSAENOBUFS(   t	   WSAEMFILE(   t   formatError(   t   EPERM(   t   EINVAL(   t   EWOULDBLOCK(   t   EINPROGRESS(   t   EALREADY(   t
   ECONNRESET(   t   EISCONN(   t   ENOTCONN(   t   EINTR(   t   ENOBUFS(   t   EMFILE(   t   ENFILE(   t   ENOMEM(   t   EAGAIN(   t   ECONNABORTED(   t   strerror(   t	   errorcode(   t   baset   addresst   fdesc(   t
   deferLater(   t   logt   failuret   reflect(   t
   unsignedID(   t   CannotListenError(   t   abstractt   maint
   interfacest   errort   _SocketCloserc           B   s   e  Z d  Z d   Z RS(   t   shutdownc         C   s   |  j  } yN | r+ t | |  j  d  n+ |  j  j t  j t  j t j d d d   Wn t  j k
 rm n Xy | j	   Wn t  j k
 r n Xd  S(   Ni   t   iii   i    (
   t   sockett   getattrt   _socketShutdownMethodt
   setsockoptt
   SOL_SOCKETt	   SO_LINGERt   structt   packR7   t   close(   t   selft   orderlyt   skt(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   _closeSocketg   s    	(   R   R	   R=   RG   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR8   d   s   t   _AbortingMixinc           B   s   e  Z d  Z e Z d   Z RS(   s   
    Common implementation of C{abortConnection}.

    @ivar _aborting: Set to C{True} when C{abortConnection} is called.
    @type _aborting: C{bool}
    c         C   sw   |  j  s |  j r d St |  _ |  j   |  j   d   |  _ d   |  _ |  j j d |  j	 t
 j t j     d S(   sf   
        Aborts the connection immediately, dropping any buffered data.

        @since: 11.1
        Nc          _   s   d  S(   N(   t   None(   t   argst   kwargs(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   <lambda>   s    c          _   s   d  S(   N(   RI   (   RJ   RK   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRL      s    i    (   t   disconnectedt	   _abortingt   Truet   stopReadingt   stopWritingt   doReadt   doWritet   reactort	   callLatert   connectionLostR0   t   FailureR7   t   ConnectionAborted(   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   abortConnection   s    	

(   R   R	   t   __doc__R
   RN   RY   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRH      s   t
   Connectionc           B   s   e  Z d  Z e e j e j  d d  Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d Z d	   Z d
   Z d   Z d   Z d   Z RS(   s
  
    Superclass of all socket-based FileDescriptors.

    This is an abstract superclass of all objects which represent a TCP/IP
    connection based socket.

    @ivar logstr: prefix used when logging events related to this connection.
    @type logstr: C{str}
    c         C   sH   t  j j |  d | | |  _ |  j j d  | j |  _ | |  _ d  S(   NRT   i    (   R4   t   FileDescriptort   __init__R;   t   setblockingt   filenot   protocol(   RD   RF   R`   RT   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR]      s
    	c         C   s   |  j  S(   s&   Return the socket for this connection.(   R;   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt	   getHandle   s    c         C   s   y |  j  j |  j  } Wn4 t  j k
 rO } | j d t k rE d St j Sn X| s] t j S|  j	 j
 |  } | d k	 r |  j	 j
 } d } t j | t j d d d d  d | } t j | |  n  | S(   s\  Calls self.protocol.dataReceived with all available data.

        This reads up to self.bufferSize bytes of data from its socket, then
        calls self.dataReceived(data) to process it.  If the connection is not
        lost through an error in the physical recv(), this function will return
        the result of the dataReceived call.
        i    NsP   Returning a value other than None from %(fqpn)s is deprecated since %(version)s.t   Twistedi   t   format(   R;   t   recvt
   bufferSizeR7   RJ   R   R5   t   CONNECTION_LOSTt   CONNECTION_DONER`   t   dataReceivedRI   R   t   getDeprecationWarningStringR   t   Versiont   warnAboutFunction(   RD   t   datat   set   rvalt   offendert   warningFormatt   warningString(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRR      s"    	c         C   s   y# |  j  j t | d |  j   SWnZ t  j k
 r } | j d t k rX |  j |  S| j d t t	 f k ru d St
 j Sn Xd S(   s  
        Write as much as possible of the given data to this TCP connection.

        This sends up to C{self.SEND_LIMIT} bytes from C{data}.  If the
        connection is lost, an exception is returned.  Otherwise, the number
        of bytes successfully written is returned.
        i    N(   R;   t   sendt   buffert
   SEND_LIMITR7   RJ   R"   t   writeSomeDataR   R#   R5   Rf   (   RD   Rl   Rm   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRu      s    #c         C   s   y t  |  j |  j  d  Wn t j k
 r3 n Xt j |  j d   } | r y | j   Wq t	 j
   } t j   |  j |  q Xn  d  S(   Ni   (   R<   R;   R=   R7   R6   t   IHalfCloseableProtocolR`   RI   t   writeConnectionLostR0   RW   R/   t   errRV   (   RD   t   pt   f(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   _closeWriteConnection   s    
c         C   sd   t  j |  j d   } | rS y | j   Wq` t j   |  j t j	    q` Xn |  j |  d  S(   N(
   R6   Rv   R`   RI   t   readConnectionLostR/   Rx   RV   R0   RW   (   RD   t   reasonRy   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR|      s    
c         C   sl   t  |  d  s d St j j |  |  |  j | j t j   |  j } |  ` |  `	 |  `
 | j |  d S(   s6   See abstract.FileDescriptor.connectionLost().
        R;   N(   t   hasattrR4   R\   RV   RG   t   checkR7   RX   R`   R;   R_   (   RD   R}   R`   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRV     s    	t   Uninitializedc         C   s   |  j  S(   sE   Return the prefix to log with when I own the logging thread.
        (   t   logstr(   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt	   logPrefix  s    c         C   s"   t  j |  j j t j t j   S(   N(   t   operatort   truthR;   t
   getsockoptt   IPPROTO_TCPt   TCP_NODELAY(   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   getTcpNoDelay  s    c         C   s    |  j  j t  j t  j |  d  S(   N(   R;   R>   R   R   (   RD   t   enabled(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   setTcpNoDelay"  s    c         C   s"   t  j |  j j t j t j   S(   N(   R   R   R;   R   R?   t   SO_KEEPALIVE(   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   getTcpKeepAlive%  s    c         C   s    |  j  j t  j t  j |  d  S(   N(   R;   R>   R?   R   (   RD   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   setTcpKeepAlive)  s    N(   R   R	   RZ   R    R6   t   ITCPTransportt   ISystemHandleRI   R]   Ra   RR   Ru   R{   R|   RV   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR[      s   
										t
   BaseClientc           B   sw   e  Z d  Z e Z e j Z e j Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z RS(
   s=   
    A base class for client TCP (and similiar) sockets.
    c         C   sa   | rG t  j |  | d |  |  j |  _ |  j |  _ | j d |  n | j d |  j |  d S(   sU   
        Called by base classes to continue to next stage of initialization.
        i    N(   R[   R]   RI   t	   doConnectRS   RR   RU   t   failIfNotConnected(   RD   t   whenDoneRF   R7   RT   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   _finishInit7  s    c         C   s   |  j  t j    d S(   s   Stop attempt to connect.N(   R   R7   t	   UserError(   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   stopConnectingC  s    c         C   s   |  j  s" |  j s" t |  d  r& d S|  j j t j |   t |  d  rk |  j   |  j   |  ` n  y |  j	 t
  Wn t k
 r n X|  ` |  ` d S(   s   
        Generic method called when the attemps to connect failed. It basically
        cleans everything it can: call connectionFailed, stop read and write,
        delete socket related members.
        t	   connectorNRT   (   t	   connectedRM   R~   R   t   connectionFailedR0   RW   RP   RQ   RG   RO   t   AttributeErrorR;   R_   (   RD   Rx   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   G  s    

	c         C   s<   t  j  |  j |  j  } | j d  t j | j    | S(   sc   (internal) Create a non-blocking socket using
        self.addressFamily, self.socketType.
        i    (   R;   t   addressFamilyt
   socketTypeR^   R-   t   _setCloseOnExecR_   (   RD   t   s(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   createInternetSocket_  s    c         C   s`   t  j |  j d  r- |  j |  j d  n/ |  j j |  j d  } | j |  j |  j  d  S(   Ni    (   R4   t   isIPAddresst   addrt   _setRealAddressRT   t   resolvet   addCallbacksR   (   RD   t   d(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   resolveAddressh  s    c         C   s$   | |  j  d f |  _ |  j   d  S(   Ni   (   R   t   realAddressR   (   RD   R,   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   o  s    c         C   sJ  t  |  d  s d S|  j j t j t j  } | rZ |  j t j | t |  f   d Sy |  j j	 |  j
  } Wn# t j k
 r } | j d } n X| r| t k r q| t t t f k s | t k r t d k r |  j   |  j   d S|  j t j | t |  f   d Sn  |  ` |  ` |  j   |  j   |  j   d S(   sm   I connect the socket.

        Then, call the protocol's makeConnection, and start waiting for data.
        R   Ni    R   (   R~   R;   R   R?   t   SO_ERRORR   R7   t   getConnectErrorR)   t
   connect_exR   RJ   R    R   R   R   R   R   t   startReadingt   startWritingRS   RR   RP   RQ   t   _connectDone(   RD   Rx   t   connectResultRm   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   s  s2    "


"

c         C   sa   |  j  j |  j    |  _ d |  _ |  j |  j  } d | |  _ |  j   |  j j |   d  S(   Ni   s	   %s,client(	   R   t   buildProtocolt   getPeerR`   R   t   _getLogPrefixR   R   t   makeConnection(   RD   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s    	
c         C   sI   |  j  s% |  j t j d |   n  t j |  |  |  j j |  d  S(   Nt   string(   R   R   R7   t   ConnectErrorR[   RV   R   (   RD   R}   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRV     s    	(   R   R	   RZ   R[   t   _baseR;   t   AF_INETR   t   SOCK_STREAMR   R   R   R   R   R   R   R   R   RV   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   .  s   										2	t   Clientc           B   s5   e  Z d  Z d d  Z d   Z d   Z d   Z RS(   s   A TCP client.c   
      C   s   | |  _  | | f |  _ |  j } d  } d  } y |  j   } Wn< t j k
 r{ }	 t j |	 j d |	 j d  } d  } n X| r | d  k	 r y | j	 |  Wq t j k
 r }	 t j |	 j d |	 j d  } d  } q Xn  |  j
 | | | |  d  S(   Ni    i   (   R   R   R   RI   R   R;   R7   t   ConnectBindErrorRJ   t   bindR   (
   RD   t   hostt   portt   bindAddressR   RT   R   Rx   RF   Rm   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR]     s"    		 
 c         C   s   t  j d |  j j    S(   s`   Returns an IPv4Address.

        This indicates the address from which I am connecting.
        t   TCP(   R,   t   IPv4AddressR;   t   getsockname(   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   getHost  s    c         C   s   t  j d |  j  S(   s\   Returns an IPv4Address.

        This indicates the address that I am connected to.
        R   (   R,   R   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s    c         C   s#   d |  j  |  j t |   f } | S(   Ns   <%s to %s at %x>(   t	   __class__R   R2   (   RD   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   __repr__  s    N(   R   R	   RZ   RI   R]   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s
   		t   Serverc           B   s8   e  Z d  Z e Z d   Z d   Z d   Z d   Z RS(   s<  
    Serverside socket-stream connection class.

    This is a serverside network connection transport; a socket which came from
    an accept() on a server.

    @ivar _base: L{Connection}, which is the base class of this class which has
        all of the useful file descriptor methods.  This is used by
        L{_TLSServerMixin} to call the right methods to directly manipulate the
        transport, as is necessary for writing TLS-encrypted bytes (whereas
        those methods on L{Server} will go through another layer of TLS if it
        has been enabled).
    c         C   s   t  j |  | | |  | |  _ | |  _ | |  _ | d |  _ |  j |  j  } d | | |  j f |  _ d |  j j	 j
 |  j |  j j f |  _ |  j   d |  _ d S(   s  
        Server(sock, protocol, client, server, sessionno)

        Initialize it with a socket, a protocol, a descriptor for my peer (a
        tuple of host, port describing the other end of the connection), an
        instance of Port, and a session number.
        i    s   %s,%s,%ss   <%s #%s on %s>i   N(   R[   R]   t   servert   clientt	   sessionnot   hostnameR   R`   R   R   R   t   _realPortNumbert   repstrR   R   (   RD   t   sockR`   R   R   R   RT   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR]     s    			
c         C   s   |  j  S(   s4   A string representation of this connection.
        (   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   	  s    c         C   s   t  j d |  j j    S(   sN   Returns an IPv4Address.

        This indicates the server's address.
        R   (   R,   R   R;   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s    c         C   s   t  j d |  j  S(   sN   Returns an IPv4Address.

        This indicates the client's address.
        R   (   R,   R   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s    (	   R   R	   RZ   R[   R   R]   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s   			t   Portc           B   s   e  Z d  Z e e j  e j Z e j	 Z
 e Z d Z d Z d Z d Z d Z d d d d  Z d   Z d   Z d   Z d	   Z d
   Z e j e j  d  Z e Z d   Z d   Z  d   Z! d   Z" RS(   s.  
    A TCP server port, listening for connections.

    When a connection is accepted, this will call a factory's buildProtocol
    with the incoming address as an argument, according to the specification
    described in L{twisted.internet.interfaces.IProtocolFactory}.

    If you wish to change the sort of transport that will be used, the
    C{transport} attribute will be called with the signature expected for
    C{Server.__init__}, so it can be replaced.

    @ivar deferred: a deferred created when L{stopListening} is called, and
        that will fire when connection is lost. This is not to be used it
        directly: prefer the deferred returned by L{stopListening} instead.
    @type deferred: L{defer.Deferred}

    @ivar disconnecting: flag indicating that the L{stopListening} method has
        been called and that no connections should be accepted anymore.
    @type disconnecting: C{bool}

    @ivar connected: flag set once the listen has successfully been called on
        the socket.
    @type connected: C{bool}

    @ivar _type: A string describing the connections which will be created by
        this port.  Normally this is C{"TCP"}, since this is a TCP port, but
        when the TLS implementation re-uses this class it overrides the value
        with C{"TLS"}.  Only used for logging.
    i    t    i2   R   c         C   s>   t  j j |  d | | |  _ | |  _ | |  _ | |  _ d S(   s5   Initialize with a numeric port to listen on.
        RT   N(   R+   t   BasePortR]   R   t   factoryt   backlogt	   interface(   RD   R   R   R   R   RT   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR]   M  s
    			c         C   sG   |  j  d  k	 r, d |  j |  j j |  j  f Sd |  j |  j j f Sd  S(   Ns   <%s of %s on %s>s   <%s of %s (not listening)>(   R   RI   R   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   V  s    c         C   sM   t  j j |   } t d k rI t j d k rI | j t j t j	 d  n  | S(   Nt   posixt   cygwini   (
   R+   R   R   R   t   syst   platformR>   R;   R?   t   SO_REUSEADDR(   RD   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR   ]  s    c         C   s   y) |  j    } | j |  j |  j f  Wn. t j k
 rY } t |  j |  j | f  n X| j   d |  _ t	 j
 d |  j |  j  |  j f  |  j j   | j |  j  t |  _ | |  _ |  j j |  _ d |  _ |  j   d S(   s   Create and bind my socket, and begin listening on it.

        This is called on unserialization, and must be called after creating a
        server to begin listening on the specified port.
        i   s   %s starting on %sid   N(   R   R   R   R   R;   R7   R3   R   R   R/   t   msgR   R   t   doStartt   listenR   RO   R   R_   t   numberAcceptsR   (   RD   RF   t   le(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   startListeningd  s    				c         C   s   | \ } } t  j d | |  S(   NR   (   R,   t   _ServerFactoryIPv4Address(   RD   t   .1R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt
   _buildAddr  s    	c   	      C   s  yt  d k r |  j } n d } xxt |  D]Z} |  j rA d Sy |  j j   \ } } Wn t j k
 r } | j d t t	 f k r | |  _ Pn^ | j d t
 k r q. nE | j d t t t t t f k r t j d t | j d f  Pn    n Xt j | j    |  j j |  j |   } | d k rD| j   q. n  |  j } | d |  _ |  j | | | |  | |  j  } | j |  q. W|  j d |  _ Wn t j   n Xd S(   s   Called when my socket is ready for reading.

        This accepts a connection and calls self.protocol() to handle the
        wire-level protocol.
        R   i   Ni    s$   Could not accept new connection (%s)i   (    R   R   t   ranget   disconnectingR;   t   acceptR7   RJ   R   R'   R   R$   R#   R%   R&   R(   R/   R   R*   R-   R   R_   R   R   R   RI   RC   R   t	   transportRT   R   t   deferr(	   RD   t
   numAcceptst   iRF   R   t   eR`   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRR     s@    		"	
	!c         C   sE   t  |  _ |  j   |  j rA t |  j d |  j |  |  _ |  j Sd S(   s  
        Stop accepting connections on this port.

        This will shut down the socket and call self.connectionLost().  It
        returns a deferred which will fire successfully when the port is
        actually closed, or with a failure if an error occurs shutting down.
        i    N(   RO   R   RP   R   R.   RT   RV   t   deferred(   RD   t   connDone(    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   loseConnection  s    	
	c         C   s!   t  j d |  j |  j f  d S(   s.   
        Log message for closing port
        s   (%s Port %s Closed)N(   R/   R   t   _typeR   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   _logConnectionLostMsg  s    c         C   sj   |  j    d |  _ t j j |  |  t |  _ |  j t	  |  `
 |  ` z |  j j   Wd t |  _ Xd S(   s'   
        Cleans up the socket.
        N(   R   RI   R   R+   R   RV   R
   R   RG   RO   R;   R_   R   t   doStopR   (   RD   R}   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyRV     s    
		c         C   s   t  j |  j j  S(   sB   Returns the name of my class, to prefix log entries with.
        (   R1   t   qualR   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s    c         C   s   t  j d |  j j    S(   sN   Returns an IPv4Address.

        This indicates the server's address.
        R   (   R,   R   R;   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s    N(#   R   R	   RZ   R    R6   t   IListeningPortR;   R   R   R   R   R   R   R   R   R   R   RI   R   R]   R   R   R   R   RR   R0   RW   R5   Rg   R   t   stopListeningR   RV   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s,   								G			t	   Connectorc           B   s&   e  Z d d   Z d   Z d   Z RS(   c         C   s   | |  _  t | t j  ri y t j | d  } Wqi t j k
 re } t j d d | | f   qi Xn  | |  _ | |  _	 t
 j j |  | | |  d  S(   Nt   tcpR   s   %s (%r)(   R   t
   isinstancet   typest   StringTypesR;   t   getservbynameR7   t   ServiceNameUnknownErrorR   R   R+   t   BaseConnectorR]   (   RD   R   R   R   t   timeoutR   RT   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR]     s    	#		c         C   s"   t  |  j |  j |  j |  |  j  S(   N(   R   R   R   R   RT   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   _makeTransport  s    c         C   s   t  j d |  j |  j  S(   NR   (   R,   R   R   R   (   RD   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   getDestination  s    N(   R   R	   RI   R]   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyR     s   	(R   RZ   R   R;   R   R   RA   t   zope.interfaceR    t   twisted.python.runtimeR   t   twisted.pythonR   R   t   twisted.internet._newtlsR   R   R   R   R   R   t   ImportErrort   twisted.internet._oldtlst   objectR   t   errnoR   R   R   R   R   R   R   R   R   R   R   R    R   R!   R   R"   R   R#   R   R$   R%   R&   R'   R(   t   twisted.python.win32R   R)   t   osR*   t   twisted.internetR+   R,   R-   t   twisted.internet.taskR.   R/   R0   R1   t   twisted.python.utilR2   t   twisted.internet.errorR3   R4   R5   R6   R7   R8   RH   R\   R[   R   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/internet/tcp.pyt   <module>	   s     			",=