'Read a datagram out of this tunnel.
@param limit: The maximum number of bytes from the datagram to return.
If the next datagram is larger than this, extra bytes are dropped
and lost forever.
@type limit: L{int}
@raise OSError: Any of the usual I/O problems can result in this
exception being raised with some particular error number set.
@raise IOError: Any of the usual I/O problems can result in this
exception being raised with some particular error number set.
@return: The datagram which was read from the tunnel.  If the tunnel
mode does not include L{TunnelFlags.IFF_NO_PI} then the datagram is
prefixed with a 4 byte PI header.
@rtype: L{bytes}'

def read(self, limit):

    if self.readBuffer:
        if (self.tunnelMode & TunnelFlags.IFF_NO_PI.value):
            header = ''
        else:
            header = ('\x00' * _PI_SIZE)
            limit -= 4
        return (header + self.readBuffer.popleft()[:limit])
    elif self.blocking:
        raise NotImplementedError()
    else:
        raise self.nonBlockingExceptionStyle
