'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.'

def writeSomeData(self, data):

    limitedData = lazyByteSlice(data, 0, self.SEND_LIMIT)
    try:
        return untilConcludes(self.socket.send, limitedData)
    except socket.error as se:
        if (se.args[0] in (EWOULDBLOCK, ENOBUFS)):
            return 0
        else:
            return main.CONNECTION_LOST
