def send(self, s):
size = len(s)<EOL>self.lock.acquire()<EOL>try:<EOL><INDENT>size = self._wait_for_send_window(size)<EOL>if size == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>m = Message()<EOL>m.add_byte(chr(MSG_CHANNEL_DATA))<EOL>m.add_int(self.remote_chanid)<EOL>m.add_string(s[:size])<EOL><DEDENT>finally:<EOL><INDENT>self.lock.release()<EOL><DEDENT>self.transport._send_user_message(m)<EOL>return size<EOL>
Send data to the channel.  Returns the number of bytes sent, or 0 if
the channel stream is closed.  Applications are responsible for
checking that all data has been sent: if only some of the data was
transmitted, the application needs to attempt delivery of the remaining
data.

@param s: data to send
@type s: str
@return: number of bytes actually sent
@rtype: int

@raise socket.timeout: if no data could be sent before the timeout set
    by L{settimeout}.