'Send a pickled string to the socket.
This function allows for partial sends which can happen when the
network is busy.'

def send(self, s):

    if (self.sock is None):
        self.createSocket()
    if self.sock:
        try:
            if hasattr(self.sock, 'sendall'):
                self.sock.sendall(s)
            else:
                sentsofar = 0
                left = len(s)
                while (left > 0):
                    sent = self.sock.send(s[sentsofar:])
                    sentsofar = (sentsofar + sent)
                    left = (left - sent)
        except socket.error:
            self.sock.close()
            self.sock = None
    return
