Eu quero executar um comando no Cmd do cliente e retorna os valores pro servidor. Já Consegui Executar o comando no Cmd do cliente... Agora como faço para retorna os valores pro servidor?
O Servidor:
import socket
import os
Host = "127.0.0.1" #str(input("Host: "))
Door = 8291 #int(input("Door: "))
conexao = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
conexao.bind((Host,Door))
conexao.listen(2)
c, e = conexao.accept()
while True:
os.system('cls')
print("Connected to : ", e)
print("\n\n")
print("|----------------|-------|")
print("| Instructions | Press |")
print("|----------------|-------|")
print("| Send Message | 1 |")
print("|----------------|-------|")
print("| Send CodeDos | 2 |")
print("|----------------|-------|")
print("\n\n")
Choice = int(input("I Pick: "))
os.system("cls")
if Choice == 1:
Msg = input("Message:")
c.send("1".encode('ascii'))
c.send(Msg.encode('ascii'))
elif Choice == 2:
Cod = input("CodeDos:")
c.send("2".encode('ascii'))
c.send(Cod.encode('ascii'))
else:
print("Faill")
os.system('pause')
O cliente:
import socket
import os
Host = "127.0.0.1" #str(input("Host: "))
Door = 8291 #int(input("Door: "))
conexao = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
conexao.connect((Host,Door))
while True:
info = conexao.recv(1024)
if info.decode('ascii') == "1": # If Choice == 1 (Message) Do:
info = conexao.recv(1024)
info = info.decode('ascii')
print(info)
elif info.decode('ascii') == "2": # If Choice == 2 (CodeDos) Do:
info = conexao.recv(1024)
info = info.decode('ascii')
os.system(info)