I have the following class, a Point object
class Point:
def __init__(self):
pass
def __init__(self, x, y):
self.x = x
self.y = y
And I have a server (Uses UDP)
# Server side
import socket
import pickle
host = "localhost"
port = 10000
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
data = s.recvfrom(1024)
print(data)
And my client side is:
import socket
import pickle
from Point import *
host = "localhost"
port = 10000
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
p = Point(10, 20)
a = pickle.dumps(p)
s.sendto(a, (host, port))
In the server side, whenever I get the p
and print it, I get the following (b'\x80\x03cPoint\nPoint\nq\x00)\x81q\x01}q\x02(X\x01\x00\x00\x00xq\x03K\nX\x01\x00\x00\x00yq\x04K\x14ub.', ('127.0.0.1', 55511))
How can I get the object, instead of this?