'set socket options with a unicode object
This is simply a wrapper for setsockopt to protect from encoding ambiguity.
See the 0MQ documentation for details on specific options.
Parameters
option : int
The name of the option to set. Can be any of: SUBSCRIBE,
UNSUBSCRIBE, IDENTITY
optval : unicode string (unicode on py2, str on py3)
The value of the option to set.
encoding : str
The encoding to be used, default is utf8'

def set_string(self, option, optval, encoding='utf-8'):

    if (not isinstance(optval, unicode)):
        raise TypeError('unicode    strings    only')
    return self.set(option, optval.encode(encoding))
