revised some variables and wording
This commit is contained in:
parent
ac7880e1c2
commit
6ab6bb5cf8
@ -39,6 +39,9 @@ def request_server_info(server_ip, server_port):
|
|||||||
request = 'PYPONGREQ;SVRINFO'
|
request = 'PYPONGREQ;SVRINFO'
|
||||||
|
|
||||||
udp_client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
udp_client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
# Timeout is set to SCAN_TIMEOUT plus a random number between 0 and SCAN_TIMEOUT so that threads can
|
||||||
|
# start asynchronously to avoid a lot of requests being sent to machines at once
|
||||||
|
# Average time is SCAN_TIMEOUT*1.5
|
||||||
udp_client_socket.settimeout(SCAN_TIMEOUT + (SCAN_TIMEOUT * random.random()))
|
udp_client_socket.settimeout(SCAN_TIMEOUT + (SCAN_TIMEOUT * random.random()))
|
||||||
try:
|
try:
|
||||||
udp_client_socket.sendto(str.encode(request, 'UTF-8'), (server_ip, server_port))
|
udp_client_socket.sendto(str.encode(request, 'UTF-8'), (server_ip, server_port))
|
||||||
|
@ -7,6 +7,9 @@ import pypong.networking.client as client
|
|||||||
|
|
||||||
global running
|
global running
|
||||||
|
|
||||||
|
# Don't allow any more than this number of threads when looking for games
|
||||||
|
# Can cripple a network at high numbers
|
||||||
|
MAX_SCAN_REQUESTS = 64
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
@ -14,7 +17,7 @@ def main():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Executor used for scanning local network for servers
|
# Executor used for scanning local network for servers
|
||||||
executor = concurrent.futures.ThreadPoolExecutor(max_workers=512)
|
executor = concurrent.futures.ThreadPoolExecutor(max_workers=MAX_SCAN_REQUESTS)
|
||||||
|
|
||||||
main_window = tk.Tk()
|
main_window = tk.Tk()
|
||||||
main_window.title('PynPong Launcher')
|
main_window.title('PynPong Launcher')
|
||||||
|
Loading…
Reference in New Issue
Block a user