def _set_tcp_keepalive(zmq_socket, opts):
 if (hasattr(zmq, 'TCP_KEEPALIVE') and opts):
  if ('tcp_keepalive' in opts):
   zmq_socket.setsockopt(zmq.TCP_KEEPALIVE, opts['tcp_keepalive'])
  if ('tcp_keepalive_idle' in opts):
   zmq_socket.setsockopt(zmq.TCP_KEEPALIVE_IDLE, opts['tcp_keepalive_idle'])
  if ('tcp_keepalive_cnt' in opts):
   zmq_socket.setsockopt(zmq.TCP_KEEPALIVE_CNT, opts['tcp_keepalive_cnt'])
  if ('tcp_keepalive_intvl' in opts):
   zmq_socket.setsockopt(zmq.TCP_KEEPALIVE_INTVL, opts['tcp_keepalive_intvl'])

def _set_tcp_keepalive ( zmq_socket , opts ) : if ( hasattr ( zmq , 'TCP_KEEPALIVE' ) and opts ) : if ( 'tcp_keepalive' in opts ) : zmq_socket . setsockopt ( zmq . TCP_KEEPALIVE , opts [ 'tcp_keepalive' ] ) if ( 'tcp_keepalive_idle' in opts ) : zmq_socket . setsockopt ( zmq . TCP_KEEPALIVE_IDLE , opts [ 'tcp_keepalive_idle' ] ) if ( 'tcp_keepalive_cnt' in opts ) : zmq_socket . setsockopt ( zmq . TCP_KEEPALIVE_CNT , opts [ 'tcp_keepalive_cnt' ] ) if ( 'tcp_keepalive_intvl' in opts ) : zmq_socket . setsockopt ( zmq . TCP_KEEPALIVE_INTVL , opts [ 'tcp_keepalive_intvl' ] )
ensure that tcp keepalives are set as specified in "opts" .