'Writes raw outgoing data. Blocks until done.
If supplied data is unicode string, encodes it to utf-8 before send.'

def send(self, raw_data):

    if (type(raw_data) == type(u'')):
        raw_data = raw_data.encode('utf-8')
    elif (type(raw_data) != type('')):
        raw_data = ustr(raw_data).encode('utf-8')
    try:
        self._send(raw_data)
        if raw_data.strip():
            self.DEBUG(raw_data, 'sent')
            if hasattr(self._owner, 'Dispatcher'):
                self._owner.Dispatcher.Event('', DATA_SENT, raw_data)
    except:
        self.DEBUG('Socket    error    while    sending    data', 'error')
        self._owner.disconnected()
