revised some variables and wording

This commit is contained in:
Nicholas Dyer 2022-12-21 13:38:33 -05:00
parent 9ab6393065
commit 07e6eec033
No known key found for this signature in database
GPG Key ID: E4E6388793FA2105
2 changed files with 7 additions and 1 deletions

View File

@ -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))

View File

@ -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('PyPong Launcher') main_window.title('PyPong Launcher')