Created
October 21, 2020 14:55
-
-
Save meaksh/ce14811669aed4f97c2f04440bb847f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#-*- coding: utf-8 -*- | |
# This is just a fixed version of https://gist.github.com/moio/13030dbf575f998cdd6bcc430da6c4fe | |
import subprocess | |
import sys | |
import zmq | |
SERVER_ADDRESS = "tcp://127.0.0.1:4505" | |
print("libzmq-%s" % zmq.zmq_version()) | |
print("pyzmq-%s" % zmq.pyzmq_version()) | |
print("Python-%s" % sys.version) | |
context = zmq.Context() | |
socket = context.socket(zmq.XSUB) | |
print("TCP_KEEPALIVE value: %s" % socket.getsockopt(zmq.TCP_KEEPALIVE)) | |
socket.connect(SERVER_ADDRESS) | |
subprocess.call("netstat -eepto | grep 4505 | grep root | grep ESTABLISHED", shell=True) | |
socket = context.socket(zmq.XSUB) | |
socket.setsockopt(zmq.TCP_KEEPALIVE, 1) | |
socket.setsockopt(zmq.TCP_KEEPALIVE_IDLE, -1) | |
print("TCP_KEEPALIVE value: %s" % socket.getsockopt(zmq.TCP_KEEPALIVE)) | |
socket.connect("tcp://127.0.0.1:4505") | |
subprocess.call("netstat -eepto | grep 4505 | grep root | grep ESTABLISHED", shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment