'Create a Socket associated with this Context.
Parameters
socket_type : int
The socket type, which can be any of the 0MQ socket types:
REQ, REP, PUB, SUB, PAIR, DEALER, ROUTER, PULL, PUSH, etc.
kwargs:
will be passed to the __init__ method of the socket class.'

def socket(self, socket_type, **kwargs):

    if self.closed:
        raise ZMQError(ENOTSUP)
    s = self._socket_class(self, socket_type, **kwargs)
    for (opt, value) in self.sockopts.items():
        try:
            s.setsockopt(opt, value)
        except ZMQError:
            pass
    return s
