'p.register(socket, flags=POLLIN|POLLOUT)
Register a 0MQ socket or native fd for I/O monitoring.
register(s,0) is equivalent to unregister(s).
Parameters
socket : zmq.Socket or native socket
A zmq.Socket or any Python object having a ``fileno()``
method that returns a valid file descriptor.
flags : int
The events to watch for.  Can be POLLIN, POLLOUT or POLLIN|POLLOUT.
If `flags=0`, socket will be unregistered.'

def register(self, socket, flags=(POLLIN | POLLOUT)):

    if flags:
        if (socket in self._map):
            idx = self._map[socket]
            self.sockets[idx] = (socket, flags)
        else:
            idx = len(self.sockets)
            self.sockets.append((socket, flags))
            self._map[socket] = idx
    elif (socket in self._map):
        self.unregister(socket)
    else:
        pass
