0
I would like to return to the customer the information of HD size beyond the available space.
Client code
import socket, pickle
HOST = 'localhost'
PORT = 9991
udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dest = (HOST, PORT)
msg = input('Entre com a mensagem:\n')
udp.sendto(msg.encode('ascii'), dest)
lista = pickle.loads(dest)
print(lista)
udp.close()
Server code
import socket, psutil, pickle
HOST = 'localhost'
PORT = 9991
udp = socket.socket(socket.AF.INET, socket.SOCK_DGRAM)
org = (HOST, PORT)
udp.bind(org)
print('Esperando receber na porta: ', PORT,'...')
(msg, cliente) = udp.recvfrom(1024)
if msg.decode('ascii') == 'disponivel':
total = round(psutil.disk_usage('/').total/(1024*1024*1024),1))
totalDisp = round(psutil.disk_usage('/').free/(1024*1024*1024),1))
resposta = print('Memoria total e: ', total, 'e a disponivel: ', totalDisp)
tup_resp = pickle.dumps(resposta)
msg.send(tup_resp)
else:
print('Argumento invalido')
udp.close()
I get the message a byte-type object is required, not 'tuple'
Dude, your codes are all inline, being impossible to analyze anything. Could [Dit] the question and fix it?
– Woss