Guest User

Untitled

a guest
Feb 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Point:
  2. def __init__(self):
  3. self.x = 0
  4. self.y = 0
  5.  
  6. def __init__(self, x, y):
  7. self.x = x
  8. self.y = y
  9.  
  10. # Server side
  11. import socket
  12. import pickle
  13.  
  14. host = "localhost"
  15. port = 10000
  16.  
  17. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  18. s.bind((host, port))
  19.  
  20. data = s.recvfrom(1024)
  21. print(data)
  22.  
  23. import socket
  24. import pickle
  25. from Point import *
  26.  
  27. host = "localhost"
  28. port = 10000
  29. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  30.  
  31. p = Point(10, 20)
  32. a = pickle.dumps(p)
  33.  
  34. s.sendto(a, (host, port))
Add Comment
Please, Sign In to add comment