Last active
October 14, 2016 02:06
-
-
Save d3m3vilurr/606a40195e72a4df0863a20b9683b808 to your computer and use it in GitHub Desktop.
quick & dirty debug terminal
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
import socket | |
import time | |
import sys | |
def main_loop(ip, port): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
while True: | |
try: | |
s.connect((ip, port)) | |
except socket.error: | |
print 'connection refused' | |
time.sleep(2) | |
continue | |
while True: | |
try: | |
data = s.recv(0x5000) | |
except socket.error: | |
break | |
if not data: | |
break | |
print data | |
if len(data): | |
s.send('\n') | |
print 'disconnect' | |
time.sleep(2) | |
if __name__ == '__main__': | |
if len(sys.argv) < 3: | |
print '%s <ip> <port>' % sys.argv[0] | |
sys.exit(1) | |
main_loop(sys.argv[1], int(sys.argv[2])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment