Guest User

Untitled

a guest
Aug 6th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. # import python modules
  2. from socket import *
  3. import win32api
  4. HOST = '' # '' means bind to all interfaces
  5. PORT = 444 # port
  6.  
  7. # create our socket handler
  8. s = socket(AF_INET, SOCK_STREAM)
  9.  
  10. # set is so that when we cancel out we can reuse port
  11. s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
  12.  
  13. # bind to interface
  14. s.bind((HOST, PORT))
  15.  
  16. # print we are accepting connections
  17. print ("Listening on 0.0.0.0:%s" % str(PORT))
  18.  
  19. # listen for only 10 connection
  20. s.listen(10)
  21.  
  22. # accept connections
  23. conn, addr = s.accept()
  24.  
  25. # print connected by ipaddress
  26. print ('Connected by', addr)
  27.  
  28. # receive initial connection
  29. """data = (conn.recv(1024)).decode('utf-8')
  30. print(data)
  31. print("ssd")
  32. #hämta skärmupplösning
  33. Width = (conn.recv(1024)).decode('utf-8')
  34. print("ssd")
  35. Height = (conn.recv(1024)).decode('utf-8')
  36. print("ssd")
  37. #skalan mellan skärmarna
  38. widhtratio = width/win32api.GetSystemMetrics(0)
  39. heightratio = heght/win32api.GetSystemMetrics(1)"""
  40.  
  41. # start loop
  42. while True:
  43. #ta fram musposition
  44. xypos = str(win32api.GetCursorPos())
  45.  
  46. conn.send((xypos).encode('utf-8'))
  47.  
  48. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment