I am reading two values i.e Data = [8, 10] on the server side and want to send it to the client side but on the client side i receive the data as "810".
Client Side:
import socket
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error as err:
print("Socket creation failed with error : ", err)
s.connect((socket.gethostname(), 9880))
print("connected to cloud.")
print(time.time(), ":\tSending request")
print(time.time(), ":\tWaiting for cloud's reply")
Data = []
for i in range(0,2):
c = s.recv(128)
c_d = c.decode()
print("Data: ",c_d)
Data.append(c_d)
Server Side:
import socket
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error as err:
print("Socket creation failed with error : ", err)
s.bind((socket.gethostname(), 9880))
s.listen(5)
while True:
print("Listening for connections ...")
c, addr = s.accept()
print("\tGot a connection!\n")
Data = [8, 10]
for i in Data:
s.send(str(i).encode())