Skip to content

Instantly share code, notes, and snippets.

@d3m3vilurr
Last active October 14, 2016 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d3m3vilurr/606a40195e72a4df0863a20b9683b808 to your computer and use it in GitHub Desktop.
Save d3m3vilurr/606a40195e72a4df0863a20b9683b808 to your computer and use it in GitHub Desktop.
quick & dirty debug terminal
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