im setting up a local network game however when i attempt to send a packet size for unpicking a dictionary i keep getting None
returned
heres my server (stripped down to the not working portion)
player1 = { # players 2-4 are the exact name but renamed
"id":1,
"x": 50,
"y": 50,
"alive": True,
"joined": False
}
def client(con, player_data):
global player1, player2, player3, player4
player = player_data
print(player)
all_players = (player1, player2, player3, player4)
msgsize = str(sys.getsizeof(all_players))
print(msgsize.encode())
con.send(msgsize.encode())
ootput of the prints
{'id': 1, 'x': 50, 'y': 50, 'alive': True, 'joined': False}
72
my client
class Network:
def __init__(self, port):
self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server = "100.115.92.197"
self.port = port
self.addr = (self.server, self.port)
def connect(self):
self.client.connect(self.addr)
def recv(self):
message_size = self.client.recv(1000).decode()
print(message_size)
clients output
None
ive tried struct and sys now
CodePudding user response:
i was doing con.send
instead of con.sendall
, i solved my issue.