Guest User

Untitled

a guest
Oct 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import socket
  2.  
  3. HOST = '' #servers host
  4. PORT = 56789
  5.  
  6. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  7. s.connect((HOST, PORT))
  8. x = '11.2 '
  9. y = '-21.5 '
  10. z = '5.6'
  11. degree = '90 '
  12. timestamp = '12:25:31'
  13. s.sendall(x, y, z, degree, timestamp)
  14. data = s.recv(1024)
  15. print 'Received', repr(data)
  16.  
  17. import socket
  18.  
  19.  
  20. HOST = '' #hostname
  21. PORT = 56789
  22.  
  23. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  24. s.bind((host, port))
  25. s.listen(1)
  26. conn, addr = s.accept()
  27.  
  28. x=None
  29. y=None
  30. z=None
  31. degree=None
  32. timestamp=None
  33.  
  34. with conn:
  35. print('Connected by', addr)
  36. while 1:
  37. data = conn.recv(1024)
  38. x = float(x)
  39. y = float(y)
  40. z = float(z)
  41. degree = float(degree)
  42. data = ((x/2), (y/2), (z/2), (degree/2), timestamp)
  43. if not data:
  44. break
  45. conn.sendall(data)
Add Comment
Please, Sign In to add comment