Created
September 9, 2016 01:16
-
-
Save nenodias/42b45a2956a19e92a19636be9ed1f555 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# *-* coding:utf-8 *-* | |
import socket | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
xinput = None | |
try: | |
xinput = raw_input | |
except: | |
xinput = input | |
ativo = True | |
s = None | |
while True: | |
try: | |
ip = xinput('Digite o ip:') | |
porta = xinput('Digite a porta:') | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((ip, int(porta))) | |
comando = True | |
while True: | |
if comando: | |
comando = xinput(s.recv(2048)) | |
if comando != 'exit' and comando: | |
s.send(comando) | |
elif comando == 'exit': | |
s.send(comando) | |
s.close() | |
ativo = False | |
break | |
if not ativo: | |
break | |
except Exception as ex: | |
print(ex) | |
break | |
finally: | |
s.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment