I am trying to make a multiplayer game in pygame, using socket and pickle. So far I have set a Server-Network file and a file which executes the main game. When trying to pass information tho, this error occurs:
File "D:/Coding/online game/game.py", line 24, in main
p2 = n.send(p)
File "D:\Coding\online game\network.py", line 27, in send
return pickle.loads(self.client.recv(2048))
EOFError: Ran out of input
Here is my code:
import socket
import pickle
class Network:
def __init__(self):
self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server = "192.168.1.10"
self.port = 5555
self.addr = (self.server, self.port)
self.p = self.connect()
print(self.p)
# Other stuff, not causing the error
def send(self, data):
try:
self.client.send(pickle.dumps(data))
return pickle.loads(self.client.recv(2048))
except socket.error as e:
print(e)
Then, I have the variable:
p2 = n.send(p)
And when I run it the error occurs. What am I doing wrong? I'd appreciate any help.