Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import python modules
- from socket import *
- import win32api
- HOST = '' # '' means bind to all interfaces
- PORT = 444 # port
- # create our socket handler
- s = socket(AF_INET, SOCK_STREAM)
- # set is so that when we cancel out we can reuse port
- s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
- # bind to interface
- s.bind((HOST, PORT))
- # print we are accepting connections
- print ("Listening on 0.0.0.0:%s" % str(PORT))
- # listen for only 10 connection
- s.listen(10)
- # accept connections
- conn, addr = s.accept()
- # print connected by ipaddress
- print ('Connected by', addr)
- # receive initial connection
- """data = (conn.recv(1024)).decode('utf-8')
- print(data)
- print("ssd")
- #hämta skärmupplösning
- Width = (conn.recv(1024)).decode('utf-8')
- print("ssd")
- Height = (conn.recv(1024)).decode('utf-8')
- print("ssd")
- #skalan mellan skärmarna
- widhtratio = width/win32api.GetSystemMetrics(0)
- heightratio = heght/win32api.GetSystemMetrics(1)"""
- # start loop
- while True:
- #ta fram musposition
- xypos = str(win32api.GetCursorPos())
- conn.send((xypos).encode('utf-8'))
- conn.close()
Advertisement
Add Comment
Please, Sign In to add comment