def socket_unbind(socket: zmq.Socket, protocol, interface=None, port=None): if protocol == 'tcp': assert port is not None and interface is None socket.unbind(f'tcp://0.0.0.0:{port}') else: assert interface is not None socket.unbind(f'tcp://{interface}')